Class R.math.Point2D
Extends
R.math.PooledMathObject.
A 2D point class with helpful methods for manipulation
Defined in: point2d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.math.Point2D(x, y)
Create a new 2D point.
|
Field Attributes | Field Name and Description |
---|---|
The "zero" point.
|
Method Attributes | Method Name and Description |
---|---|
add(point)
A method that mutates this point by adding the point to it.
|
|
addScalar(scalar)
A mutator method that adds the scalar value to each component of this point.
|
|
convolve(point)
A mutator method that multiplies the components of this point with another.
|
|
convolveInverse(point)
A mutator method that divides the components of this point by another.
|
|
dist(point)
Returns the distance between this and another point.
|
|
div(scalar)
A mutator method that divides the components of this point by a scalar value.
|
|
equals(point)
Returns true if this point is equal to the specified point.
|
|
Return the classname of the this object
|
|
isZero()
Returns true if the point is the zero point.
|
|
mul(scalar)
A mutator methor that multiplies the components of this point by a scalar value.
|
|
neg()
A mutator method that negates this point, inversing it's components.
|
|
release()
Release this point into the pool for reuse.
|
|
set(x, y)
Set the position of a 2D point.
|
|
setX(x)
Set the X coordinate.
|
|
setY(y)
Set the Y coordinate.
|
|
simplify()
Returns a simplified version of a R.math.Point2D.
|
|
sub(point)
A mutator method that subtracts the specified point from this point.
|
|
toString()
Returns a printable version of this object fixed to two decimal places.
|
|
transform(matrix)
Mutator method which transforms this point by the specified matrix
|
- Methods borrowed from class R.math.PooledMathObject:
- destroy
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toXML
Class Detail
R.math.Point2D(x, y)
Create a new 2D point.
- Parameters:
- x
- {R.math.Point2D|Number} If this arg is a R.math.Point2D, its values will be copied into the new point.
- y
- {Number} The Y coordinate of the point. Only required if X was a number.
Field Detail
ZERO
The "zero" point. This point should not be modified.
Method Detail
{R.math.Point2D}
add(point)
A method that mutates this point by adding the point to it.
- Parameters:
- point
- {R.math.Point2D} A point
- Returns:
- {R.math.Point2D} This point
{R.math.Point2D}
addScalar(scalar)
A mutator method that adds the scalar value to each component of this point.
- Parameters:
- scalar
- {Number} A number
- Returns:
- {R.math.Point2D} This point
{R.math.Point2D}
convolve(point)
A mutator method that multiplies the components of this point with another.
- Parameters:
- point
- {R.math.Point2D} A point
- Returns:
- {R.math.Point2D} This point
{R.math.Point2D}
convolveInverse(point)
A mutator method that divides the components of this point by another. The point
cannot contain zeros for its components.
- Parameters:
- point
- {R.math.Point2D} A point
- Returns:
- {R.math.Point2D} This point
{Number}
dist(point)
Returns the distance between this and another point.
- Parameters:
- point
- {R.math.Point2D} The point to compare against
- Returns:
- {Number} The distance between the two points
{R.math.Point2D}
div(scalar)
A mutator method that divides the components of this point by a scalar value.
- Parameters:
- scalar
- {Number} A number - cannot be zero
- Returns:
- {R.math.Point2D} This point
{Boolean}
equals(point)
Returns true if this point is equal to the specified point.
- Parameters:
- point
- {R.math.Point2D} The point to compare to
- Returns:
- {Boolean} true if the two points are equal
{String}
getClassName()
Return the classname of the this object
- Returns:
- {String} "R.math.Point2D"
{Boolean}
isZero()
Returns true if the point is the zero point.
- Returns:
- {Boolean} true if the point's elements are both zero.
{R.math.Point2D}
mul(scalar)
A mutator methor that multiplies the components of this point by a scalar value.
- Parameters:
- scalar
- {Number} A number
- Returns:
- {R.math.Point2D} This point
{R.math.Point2D}
neg()
A mutator method that negates this point, inversing it's components.
- Returns:
- {R.math.Point2D} This point
release()
Release this point into the pool for reuse.
set(x, y)
Set the position of a 2D point.
- Parameters:
- x
- {R.math.Point2D|Number|Array} If this arg is a R.math.Point2D, its values will be copied into the new point.
- y
- {Number} The Y coordinate of the point. Only required if X was a number.
setX(x)
Set the X coordinate.
- Parameters:
- x
- {Number} The X coordinate
setY(y)
Set the Y coordinate.
- Parameters:
- y
- {Number} The Y coordinate
{Array}
simplify()
Returns a simplified version of a R.math.Point2D. The simplified version is
an array with two elements: X, Y.
- Returns:
- {Array}
{R.math.Point2D}
sub(point)
A mutator method that subtracts the specified point from this point.
- Parameters:
- point
- {Point2D} a point
- Returns:
- {R.math.Point2D} This point
{String}
toString()
Returns a printable version of this object fixed to two decimal places.
- Returns:
- {String} Formatted as "x,y"
{R.math.Point2D}
transform(matrix)
Mutator method which transforms this point by the specified matrix
- Parameters:
- matrix
- {Matrix} The matrix to transform this point by. Matrix is defined in the Sylvester library.
- Returns:
- {R.math.Point2D} This point