Point2
-
class
Point2()
Constructors
Methods
-
Point2.add() - add(pt:
Point2): thisAdds a point to this one
Parameters
pt:
Point2the point whose values will be addedReturns: this
the point object
-
Point2.assign() - assign(pt:
Point2): thisSets this point equal to another point
Parameters
pt:
Point2the point whose values will be used to set this objectReturns: this
the point object
-
Point2.equals() - equals(pt:
Point2): booleanCompares this point with another point
Parameters
pt:
Point2the point to compare withReturns: boolean
True if the values of this point equal the other. False otherwise.
-
Point2.length() - length(): number
Returns the length of this point
Returns: number
the point length
-
Point2.scale() - scale(k: number): this
Scales the point by a constant value
Parameters
k: number
the value to scale byReturns: this
the point object
-
Point2.set() - set(x: number, y: number): this
Sets the values of this point
Parameters
x: number
value to set for xy: number
value to set for yReturns: this
the point object
-
Point2.squaredLength() - squaredLength(): number
Returns the squared length of this vector.
Returns: number
Vector squared length.
-
Point2.subtract() - subtract(pt:
Point2): thisSubtracts a point from this one
Parameters
pt:
Point2the point whose values will be subtractedReturns: this
the point object
-
Point2.toJson() - toJson():
IPoint2Creates an object ready for JSON serialization.
Returns:
IPoint2The prepared object.
-
static Point2.distance() static
Calculate distance between two points
Parameters
Returns: number
the distance between p1 and p2
-
static Point2.fromJson() static
fromJson(objData: unknown):Point2Creates a new [[Point2]] from an object given by [[toJson]].
Parameters
objData: unknown
An object given by [[toJson]].Returns:
Point2The prepared object.
-
static Point2.scale() static
Scale a point by a constant factor
Parameters
Returns:
Point2The scaled point