# G2D Point Object

This subset of the G2D Library provide one object and some methods to handle 2d points.

• G2D.Point:Distance(point2D)
• G2D.Point:DotProduct(point2D)
• G2D.Point:MidPoint(point2D, NewObject)
• G2D.Point:New(x, y)
• G2D.Point:Normal2D(Point2D, s)
• G2D.Point:Normalize()
• G2D.Point:Rotate(point, angle)
• G2D.Point:Scale(point, scaleW, scaleH)

## G2D.Point:Distance(point2D)

`value = G2D.Point:Distance(point)`

Returns the distance between the object and the given 'point' object.

INPUT

• point : The target point for the distance calculation

OUTPUT

• value : The distance between the source point and the given 'point'

## G2D.Point:DotProduct(point2D)

`value = G2D.Point:DotProduct(point2D)`

Returns the sum of the two point's coordinates products

INPUT

• point2D : Reference point

OUTPUT

• value : Calculated product.

## G2D.Point:MidPoint(point2D, NewObject)

`result = G2D.Point:MidPoint(point2D, NewObject)`

Returns a table with the mid point coordinates or a new initialized object representing the middle point between the source point and the given 'point2D'.

INPUT

• point2D : Reference point
• NewObject : True : returns a new initialized point object, False : returns a table with the 'x' and 'y' members. Default = False.

OUTPUT

• result : Depending on 'NewObject' you can have a table with 'x' and 'y' members or a new initialized point object.

## G2D.Point:New(x, y)

`pointObj = G2D.Point:New(x, y)`

Creates an object to represent a 2d point.
'x' and 'y' are the optional initial coordinates, default values are (0, 0)

INPUT

• x : Optional horizontal coordinate, default = 0
• y : Optional vertical coordinate, default = 0

OUTPUT

• pointObj : New point object

## G2D.Point:Normal2D(Point2D, s)

`normalized = G2D.Point:Normal2D(point2D)`

Returns a new object with normalized coordinates.

INPUT

• point2D : Reference point

OUTPUT

• normalized : Normalized point object

## G2D.Point:Normalize()

`G2D.Point:Normalize()`

Normalize the point object's coordinates

## G2D.Point:Rotate(point, angle)

`G2D.Point:Rotate(point, angle)`

Rotates a point around the given anchor point

INPUT

• point : A point object to represent an anchor point
• angle : Rotation angle in degrees

## G2D.Point:Scale(point, scaleW, scaleH)

`G2D.Point:Scale(point, scaleW, scaleH)`

Scales the distance between the source object and the given point.

INPUT

• point : Point used as a reference for the distance calculation
• scaleW : Horizontal scaling factor
• scaleH : Vertical scaling factor

hollywoodlibs/g2d/point.txt · Ultima modifica: 2017/04/24 21:41 da admin 