File: ../../Developer.FoundationDotJS.org/wwwroot/Library/Foundation.Geometry.js

Foundation
Class Point

Object
  
 
 
Foundation.Point

All Implemented Interfaces:

Class


Foundation.Point

implements Foundation.Class

Two dimensional point class with x and y.


Constructor Summary
Foundation.Point(/*Number*/ x, /*Number*/ y)
Creates a point from an x and y.
Foundation.Point(/*Point*/ point)
Creates a point from another point.

Field Summary
Numberx
The x value of the point.
Numbery
The y value of the point.

Method Summary
[this]add(/*Point*/ point)
Positively offsets the point by another point.
[this]add(/*Number*/ x, /*Number*/ y)
Positively offsets the point by x and y values.
Numberangle(/*Point*/ point)
The angle from another point.
[this]ceil()
Ceils both the x and y values of the point.
Pointclone()
Creates a copy of the point.
 dispose()
Numberdistance(/*Point*/ point)
The distance to another point.
Booleanequals(/*Point*/ point)
Compares a point with another point.
Booleanequals(/*Number*/ x, /*Number*/ y)
Compares a point with x and y values.
[this]floor()
Floors both the x and y values of the point.
Numbermagnitude()
The magnitude of the point as a vector.
static Pointparse(/*String*/ pointString)
Parses a string representation of a point into a new Foundation.Point.
[this]rotate(/*Number*/ radians)
Rotates the point by an angle.
[this]round()
Rounds both the x and y values of the point.
[this]scale(/*Number*/ scale)
Scales the point.
[this]set(/*Point*/ point)
Sets the point equal to another point.
[this]set(/*Number*/ x, /*Number*/ y)
Sets the point equal to x and y values.
[this]sign()
Sets the point to one of nine absolute directions based on the x,y values. The x and y values will each become -1, 0, or 1 depending on whether each was less than, equal to, or greater than 0.
[this]subtract(/*Point*/ point)
Negatively offsets the point by another point.
[this]subtract(/*Number*/ x, /*Number*/ y)
Negatively offsets the point by x and y values.
StringtoString()
A string representation of the point.
[this]transform(/*TMatrix*/ tMatrix)
Transforms the point by an transformation matrix.

Methods inherited from Foundation.Class
getTypePath, isInstanceOf

Constructor Detail

Point

Foundation.Point(/*Number*/ x,
                 /*Number*/ y)

Creates a point from an x and y.

Parameters:
x - 
X value.
y - 
Y value.

Point

Foundation.Point(/*Point*/ point)

Creates a point from another point.

Parameters:
point - 
Point to copy.

Field Detail

x

Number x

The x value of the point.


y

Number y

The y value of the point.

Method Detail

add

[this] add(/*Point*/ point)

Positively offsets the point by another point.

Parameters:
point - 
Other point add by.
Returns:
The point (this) after addition.
See Also:
subtract, set, scale

add

[this] add(/*Number*/ x,
           /*Number*/ y)

Positively offsets the point by x and y values.

Parameters:
x - 
X value to add by.
y - 
Y value to add by.
Returns:
The point (this) after addition.
See Also:
subtract, set, scale

angle

Number angle(/*Point*/ point)

The angle from another point.

Parameters:
point - 
(Optional) The other point (or 0,0 if not passed).
Returns:
The angle from the other point, in radians.
See Also:
distance

ceil

[this] ceil()

Ceils both the x and y values of the point.

Returns:
The point (this) after ceiling.
See Also:
floor, round

clone

Point clone()

Creates a copy of the point.

Returns:
A new copy of the point.

dispose

dispose()
Overrides:
dispose in class Class

distance

Number distance(/*Point*/ point)

The distance to another point.

Parameters:
point - 
The other point.
Returns:
The distance to the other point.
See Also:
magnitude, angle

equals

Boolean equals(/*Point*/ point)

Compares a point with another point.

Parameters:
point - 
Other point to compare to.
Returns:
True if the points equal, else false.

equals

Boolean equals(/*Number*/ x,
               /*Number*/ y)

Compares a point with x and y values.

Parameters:
x - 
X value to compare to.
y - 
Y value to compare to.
Returns:
True if the points equals the x and y values, else false.

floor

[this] floor()

Floors both the x and y values of the point.

Returns:
The point (this) after flooring.
See Also:
round, ceil

magnitude

Number magnitude()

The magnitude of the point as a vector.

Returns:
The magnitude to the point.
See Also:
distance

parse

static Point parse(/*String*/ pointString)

Parses a string representation of a point into a new Foundation.Point.

Parameters:
pointString - 
The string representation of the point.
Returns:
The new point.
See Also:
toString

rotate

[this] rotate(/*Number*/ radians)

Rotates the point by an angle.

Parameters:
radians - 
The angle (in radians) to rotate the point by.
Returns:
The point (this) after rotating.

round

[this] round()

Rounds both the x and y values of the point.

Returns:
The point (this) after rounding.
See Also:
floor, ceil

scale

[this] scale(/*Number*/ scale)

Scales the point.

Parameters:
scale - 
The amount to scale by.
Returns:
The point (this) after scaling.
See Also:
add, subtract, set

set

[this] set(/*Point*/ point)

Sets the point equal to another point.

Parameters:
point - 
Other point to set by.
Returns:
The point (this) after setting.
See Also:
add, subtract, scale

set

[this] set(/*Number*/ x,
           /*Number*/ y)

Sets the point equal to x and y values.

Parameters:
x - 
X value to set by.
y - 
Y value to set by.
Returns:
The point (this) after setting.
See Also:
add, subtract, scale

sign

[this] sign()

Sets the point to one of nine absolute directions based on the x,y values. The x and y values will each become -1, 0, or 1 depending on whether each was less than, equal to, or greater than 0.

Returns:
The point (this) after signing.

subtract

[this] subtract(/*Point*/ point)

Negatively offsets the point by another point.

Parameters:
point - 
Other point subtract by.
Returns:
The point (this) after subtraction.
See Also:
add, set, scale

subtract

[this] subtract(/*Number*/ x,
                /*Number*/ y)

Negatively offsets the point by x and y values.

Parameters:
x - 
X value to subtract by.
y - 
Y value to subtract by.
Returns:
The point (this) after subtraction.
See Also:
add, set, scale

toString

String toString()

A string representation of the point.

Overrides:
toString in class Class
Returns:
The point as a '[x,y]' string.
See Also:
parse

transform

[this] transform(/*TMatrix*/ tMatrix)

Transforms the point by an transformation matrix.

Parameters:
tMatrix - 
The transformation matrix.
Returns:
The point (this) after transforming.