Kiwi.Geom.Point Class
Represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
Constructor
Kiwi.Geom.Point
-
[x=0]
-
[y=0]
Parameters:
-
[x=0]
Number optionalPosition of this point on the x-axis.
-
[y=0]
Number optionalPosition of this point on the y-axis.
Item Index
Methods
Methods
add
-
toAdd
-
output
Adds the coordinates of another point to the coordinates of this point to create a new point.
Parameters:
-
toAdd
Kiwi.Geom.PointThe point to be added.
-
output
Kiwi.Geom.Point
Returns:
The new Point object.
addTo
-
x
-
y
Adds the given values to the coordinates of this point and returns it
Parameters:
-
x
NumberThe amount to add to the x value of the point
-
y
NumberThe amount to add to the x value of the point
Returns:
This Point object.
angleTo
-
target
Get the angle from this Point object to given Point object.
Parameters:
-
target
Kiwi.Geom.Pointdestination Point object.
Returns:
angle to point
angleToXY
-
x
-
y
Get the angle from this Point object to given X,Y coordinates.
Parameters:
-
x
Numberx value.
-
y
Numbery value.
Returns:
angle to point.
clamp
-
min
-
max
Clamps this Point object to be between the given min and max.
Parameters:
-
min
NumberThe minimum value to clamp this Point to.
-
max
NumberThe maximum value to clamp this Point to.
Returns:
This Point object.
clampX
-
min
-
max
Clamps the x value of this Point object to be between the given min and max
Parameters:
-
min
NumberThe minimum value to clamp this Point to
-
max
NumberThe maximum value to clamp this Point to
Returns:
This Point object.
clampY
-
min
-
max
Clamps the y value of this Point object to be between the given min and max
Parameters:
-
min
NumberThe minimum value to clamp this Point to
-
max
NumberThe maximum value to clamp this Point to
Returns:
This Point object.
clone
-
[output]
Creates a copy of this Point.
Parameters:
-
[output]
Kiwi.Geom.Point optionalOptional Point object. If given the values will be set into this object, otherwise a new Point object will be created.
Returns:
copyFrom
-
source
Copies the point data from the source Point object into this Point object.
Parameters:
-
source
Kiwi.Geom.PointThe point to copy from.
Returns:
This Point object. Useful for chaining method calls.
copyTo
-
target
Copies the point data from this Point object to the given target Point object.
Parameters:
-
target
Kiwi.Geom.Pointtarget - The point to copy to.
Returns:
The target Point object.
distanceBetween
-
pointA
-
pointB
-
[round=false]
Returns the distance between the two Point objects.
Parameters:
-
pointA
Kiwi.Geom.PointThe first Point object.
-
pointB
Kiwi.Geom.PointThe second Point object.
-
[round=false]
Boolean optionalRound the distance to the nearest integer (default false)
Returns:
The distance between the two Point objects.
distanceCompare
-
target
-
distance
Returns true if the distance between this point and a target point is greater than or equal a specified distance. This avoids using a costly square root operation
Parameters:
-
target
Kiwi.Geom.PointThe Point object to use for comparison.
-
distance
NumberThe distance to use for comparison.
Returns:
True if distance is >= specified distance.
distanceTo
-
target
-
round
Returns the distance from this Point object to the given Point object.
Parameters:
-
target
Kiwi.Geom.PointThe destination Point object.
-
round
BooleanRound the distance to the nearest integer (default false)
Returns:
The distance between this Point object and the destination Point object.
distanceToXY
-
x
-
y
-
[round=false]
Returns the distance from this Point object to the given Point object.
Parameters:
-
x
NumberThe x value.
-
y
NumberThe y value.
-
[round=false]
Boolean optionalRound the distance to the nearest integer (default false)
Returns:
The distance between this Point object and the x/y values.
equals
-
point
Determines whether this Point object and the given point object are equal. They are equal if they have the same x and y values.
Parameters:
-
point
Kiwi.Geom.PointThe point to compare against.
Returns:
A value of true if the object is equal to this Point object; false if it is not equal.
interpolate
-
pointA
-
pointB
-
f
Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2.
The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).
Parameters:
-
pointA
Kiwi.Geom.PointThe first Point object.
-
pointB
Kiwi.Geom.PointThe second Point object.
-
f
NumberThe level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
Returns:
The new interpolated Point object.
invert
()
Kiwi.Geom.Point
public
Inverts the x and y values of this point
Returns:
This Point object.
objType
()
String
public
The type of this object.
Returns:
"Point"
offset
-
dx
-
dy
Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.
Parameters:
-
dx
NumberThe amount by which to offset the horizontal coordinate, x.
-
dy
NumberThe amount by which to offset the vertical coordinate, y.
Returns:
This Point object. Useful for chaining method calls.
polar
-
length
-
angle
Creates a new point with cartesian coordinates from a pair of polar coordinates
Parameters:
-
length
NumberThe length coordinate of the polar pair.
-
angle
NumberThe angle, in radians, of the polar pair.
Returns:
The new Cartesian Point object.
polar
-
length
-
angle
Converts a pair of polar coordinates to a Cartesian point coordinate and sets them on the point instance.
Parameters:
-
length
NumberThe length coordinate of the polar pair.
-
angle
NumberThe angle, in radians, of the polar pair.
Returns:
The new Cartesian Point object.
setTo
-
x
-
y
Sets the x and y values of this Point object to the given coordinates.
Parameters:
-
x
NumberThe horizontal position of this point.
-
y
NumberThe vertical position of this point.
Returns:
This Point object. Useful for chaining method calls.
subtract
-
point
-
output
Subtracts the coordinates of another point from the coordinates of this point to create a new point.
Parameters:
-
point
Kiwi.Geom.PointThe point to be subtracted.
-
output
Kiwi.Geom.PointOptional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
Returns:
The new Point object.
subtractFrom
-
x
-
y
Adds the given values to the coordinates of this point and returns it
Parameters:
-
x
NumberThe amount to subtract from the x value of the point
-
y
NumberThe amount to subtract from the x value of the point
Returns:
This Point object.
toString
()
String
public
Returns a string representation of this object.
Returns:
a string representation of the instance.
Properties
x
Number
public
The horizontal position of this point.
y
Number
public
The vertical position of this point.