Point2 Values

The Point2 class defines the characteristics of points in 2D space. This class is a 2D version of Point3 and is used in utility rollout positioning parameters and for accessing Bitmap values, etc. See also 2D and 3D Point Literals.

Literals

[ <expr>, <expr> ]

Examples:

[x, y]

[10, 20]

[sin x, cos x]

Constructors

point2 <x> <y>        -- x and y are numbers

<point3> as point2    -- created from the x and y components of the point3

Properties

<point2>.x            : Float

<point2>.y            : Float

Operators

<point2> == <point2>

<point2> != <point2>

<point2> + <point2_or_number>

<point2> - <point2_or_number>

<point2> * <point2_or_number>

<point2> / <point2_or_number>

Standard vector arithmetic. If the second operand is a number it does scalar arithmetic on vector.

- <point2>

unary minus

Methods

copy <point2>

Creates a new copy of the point2 value. For example:

newPoint = copy oldPoint

The new value contains a copy of the input point2 value, and is independent of the input point2 value.

random <point2> <point2>

Generates a pseudo-random point between the given points.

length <point2>

Returns the length of the vector.

distance <point2> <point2>

Returns the distance between the points - length of (point 2 û point 1).

normalize <point2>

Returns the point2 value normalized such that the vector length equals 1.