| Package | pegas.geom |
| Class | public class Point |
| Inheritance | Point Vector2 |
The following code creates a point at (0,0) :
var myPoint:Point = new Point() ;
| Property | Defined by | ||
|---|---|---|---|
| angle : Number
Determinates the angle value of this Point object.
| Point | ||
| length : Number
Returns the length of the line segment from (0,0) to this point.
| Point | ||
![]() | x : Number
Defined the x coordinate.
| Vector2 | |
![]() | y : Number
Defined the y coordinate.
| Vector2 | |
![]() | ZERO : Vector2
[static]
Defines the Vector2 object with the x and y properties set to zero.
| Vector2 | |
| Method | Defined by | ||
|---|---|---|---|
|
Point(... arguments)
Creates a new Point instance.
| Point | ||
|
abs():void
Transform the coordinates of this point to used absolute value for the x and y properties.
| Point | ||
|
Returns a new Point reference with the absolute value of the coordinates of this Point object.
| Point | ||
![]() |
addition(v:*):void
Computes the addition of two vectors.
| Vector2 | |
|
angleBetween(p:Point):Number
Returns the angle value between this Point object and the specified Point passed in arguments.
| Point | ||
|
clone():*
Returns the shallow copy of this object.
| Point | ||
|
Returns the cross value of the current Point object with the Point passed in argument.
| Point | ||
|
[static]
Returns the distance between
p1 and p2 the 2 Points reference passed in argument. | Point | ||
|
Returns the dot value of the current Point and the specified Point passed in argument.
| Point | ||
|
equals(o:*):Boolean
Compares the specified object with this object for equality.
| Point | ||
|
Returns the direction of this Point.
| Point | ||
|
getLength():Number
Returns the length of the line segment from (0,0) to this point.
| Point | ||
|
[static]
Returns the middle Point between 2 Points.
| Point | ||
|
Returns the normal value of this Point.
| Point | ||
|
getProjectionLength(p:Point):Number
Returns the size of the projection of this Point with an other Point.
| Point | ||
|
[static]
Determines a point between two specified points.
| Point | ||
|
Returns
true if the Point is perpendicular with the passed-in Point. | Point | ||
|
Returns the new Point with the maximum horizontal coordinate and the maximum vertical coordinate.
| Point | ||
|
Returns a new Point with the minimum horizontal coordinate and the minimize vertical coordinate.
| Point | ||
|
negate():void
Sets this Point with negate coordinates.
| Point | ||
|
Returns the new negate Point of this Point.
| Point | ||
|
normalize(thickness:Number):void
Scales the line segment between (0,0) and the current point to a set length.
| Point | ||
|
offset(dx:Number, dy:Number):void
Offsets the Point object by the specified amount.
| Point | ||
|
plus(p:*):void
Adds the coordinates of another point to the coordinates of this point.
| Point | ||
|
Adds the coordinates of another point to the coordinates of this point to create a new point.
| Point | ||
|
[static]
Converts a pair of polar coordinates to a Cartesian point coordinate.
| Point | ||
|
Returns the projection of a Point with the specified Point passed in argument.
| Point | ||
|
reset(x:Number, y:Number):void
Sets the horizontal and vertical coordinates of this Point.
| Point | ||
|
rotate(angle:Number):void
Rotates the Point with the specified angle in argument.
| Point | ||
|
Rotates the Point with the specified
angle in argument and creates a new Point. | Point | ||
![]() |
scale(value:Number):void
Scales the vector object with the input value.
| Vector2 | |
|
Rotates the Point with the specified
s value in argument and creates a new Point. | Point | ||
![]() |
substraction(v:*):void
Computes the substraction of the current vector object with an other.
| Vector2 | |
|
Subtracts the coordinates of another point from the coordinates of this point to create a new point.
| Point | ||
|
Swap the horizontal and vertical coordinates of two Point objects.
| Point | ||
![]() |
toFlash():Point
Returns a flash.geom.Point reference of this object.
| Vector2 | |
![]() |
toObject():Object
Returns the Object representation of this object.
| Vector2 | |
|
toSource(indent:int = 0):String
Returns a Eden represensation of the object.
| Point | ||
![]() |
toString():String
Returns the string representation of the object.
| Vector2 | |
| angle | property |
angle:Number [read-write]Determinates the angle value of this Point object.
Example :
var p1:Point = new Point(0,10) ; var p2:Point = new Point(10,10) ; trace(p1.getAngle()) ; // 90 trace(p2.getAngle()) ; // 45Implementation
public function get angle():Number
public function set angle(value:Number):void
| length | property |
length:Number [read-write]Returns the length of the line segment from (0,0) to this point.
Example :
var p:Point = new Point(0,5) ; trace(p.length) ; // 5Implementation
public function get length():Number
public function set length(value:Number):void
| Point | () | constructor |
public function Point(... arguments)Creates a new Point instance.
Parameters
Example :
import pegas.geom.Point ;
var p1:Point = new Point() ;
trace(p1) ; // [Point:{0,0}]
var p2:Point = new Point( new Point(25,30) ) ;
trace(p2) ; // [Point:{25,30}]
var p3:Point = new Point( 25,30 ) ;
trace(p3) ; // [Point:{25,30}]
Parameters
... arguments |
| abs | () | method |
public function abs():voidTransform the coordinates of this point to used absolute value for the x and y properties.
Example :
var p:Point = new Point(-10, -20) ;
p.abs() ;
trace(p) ; // [Point:{10,20}]
| absNew | () | method |
public function absNew():PointReturns a new Point reference with the absolute value of the coordinates of this Point object.
Example :
var p1:Point = new Point(-10, -20) ;
var p2:Point = p1.absNew() ;
trace(p1 + " / " + p2) ; // [Point:{-10,-20}] / [Point:{10,20}]
Returns
Point —
a new Point reference with the absolute value of the coordinates of this Point object.
|
| angleBetween | () | method |
public function angleBetween(p:Point):NumberReturns the angle value between this Point object and the specified Point passed in arguments.
Example :
var p1:Point = new Point(10, 20) ; var p2:point = new Point(50, 200) ; var angle:Number = p1.angleBetween(p2) ;Parameters
p:Point |
Number — the angle value between this Point object and the specified Point passed in arguments.
|
| clone | () | method |
public override function clone():*Returns the shallow copy of this object.
Example :
var p1:Point = new Point(10, 20) ;
var p2:point = p1.clone() ;
Returns
* — the shallow copy of this object.
|
| cross | () | method |
public function cross(p:Point):NumberReturns the cross value of the current Point object with the Point passed in argument.
var p1:Point = new Point(10,20) ;
var p2:Point = new Point(40,60) ;
trace(p1.cross(p2)) ; // -200
Parameters
p:Point — The Point object use to calculate the cross value.
|
Number — The cross value of the current Point object with the Point passed in argument.
|
| distance | () | method |
public static function distance(p1:Point, p2:Point):Number
Returns the distance between p1 and p2 the 2 Points reference passed in argument.
Example :
var p1:Point = new Point(10,20) ; var p2:Point = new Point(40,60) ; trace( Point.distance(p1,p2) ) ; // 50Parameters
p1:Point — the first Point.
|
|
p2:Point — the second Point.
|
Number — the distance between p1 and p2 the 2 Points reference passed in argument.
|
| dot | () | method |
public function dot(p:Point):NumberReturns the dot value of the current Point and the specified Point passed in argument.
Example :
var p1:Point = new Point(10,20) ; var p2:Point = new Point(40,60) ; trace(p1.dot(p2)) ; // 1600Parameters
p:Point — the Point to calculate the dot value of the current Point.
|
Number — the dot value of the current Point and the specified Point passed in argument.
|
| equals | () | method |
public override function equals(o:*):BooleanCompares the specified object with this object for equality.
Example :
var p1:Point = new Point(10,20) ;
var p2:Point = new Point(10,20) ;
var p3:Point = new Point(30,40) ;
trace(p1.equals(p2)) ; // true
trace(p1.equals(p3)) ; // false
Parameters
o:* |
Boolean — true if the the specified object is equal with this object.
|
| getDirection | () | method |
public function getDirection():PointReturns the direction of this Point.
Example :
var p1 : Point = new Point(10,2); var p2 : Point = p1.getDirection(); trace( p2.getDirection() ) ;Returns
Point —
the direction of this Point.
|
See also
| getLength | () | method |
public function getLength():NumberReturns the length of the line segment from (0,0) to this point.
Example :
var p:Point = new Point(0,5) ; trace(p.getLength()) ; // 5Returns
Number — the length of the line segment from (0,0) to this point.
|
| getMiddle | () | method |
public static function getMiddle(p1:Point, p2:Point):PointReturns the middle Point between 2 Points.
Example :
var p1:Point = new Point(10,10) ;
var p2:Point = new Point(20,20) ;
var middle:Point = Point.getMiddle(p1,p2) ;
trace(middle) ;
Parameters
p1:Point |
|
p2:Point |
Point —
the middle Point between 2 Points.
|
| getNormal | () | method |
public function getNormal():PointReturns the normal value of this Point.
Example :
var p:Point = new Point(10,10) ;
var n:Point = p.getNormal() ; // [Point:{-10,10}]
trace(n) ;
Returns
Point —
the normal value of this Point.
|
| getProjectionLength | () | method |
public function getProjectionLength(p:Point):NumberReturns the size of the projection of this Point with an other Point.
Example :
var p1:Point = new Point(10,10) ;
var p2:Point = new Point(100,200) ;
var size:Number = p1.getProjectionLength(p2) ;
trace(size) ; // 0.06
Parameters
p:Point — the Point use to calculate the length of the projection.
|
Number — the size of the projection of this Point with an other Point.
|
| interpolate | () | method |
public static function interpolate(p1:Point, p2:Point, f:Number):Point
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 p1 and p2.
The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter p1).
The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter p2).
Example :
var p1:Point = new Point(10,10) ;
var p2:Point = new Point(40,40) ;
var p3:Point ;
p3 = Point.interpolate( p1 , p2, 0 ) ;
trace(p3) ; // [Point:{40,40}]
p3 = Point.interpolate( p1 , p2, 1 ) ;
trace(p3) ; // [Point:{10,10}]
p3 = Point.interpolate( p1 , p2, 0.5 ) ;
trace(p3) ; // [Point:{25,25}]
Parameters
p1:Point — The first point.
|
|
p2:Point — The second Point.
|
|
f:Number — the The level of interpolation between the two points. Indicates where the new point will be, along the line between p1 and p2. If f=1, pt1 is returned; if f=0, pt2 is returned.
|
Point —
The new interpolated point.
|
| isPerpTo | () | method |
public function isPerpTo(p:Point):Boolean
Returns true if the Point is perpendicular with the passed-in Point.
Example :
var p1:Point = new Point(0,10) ; var p2:Point = new Point(10,10) ; var p3:Point = new Point(10,0) ; trace(p1.isPerpTo(p2)) ; // false trace(p1.isPerpTo(p3)) ; // trueParameters
p:Point — the Point use to determinate if this Point object is perpendicular.
|
Boolean — true if the Point is perpendicular with the passed-in Point.
|
| max | () | method |
public function max(p:Point):PointReturns the new Point with the maximum horizontal coordinate and the maximum vertical coordinate.
Example :
var p1:Point = new Point(10,100) ;
var p2:Point = new Point(100,10) ;
var p3:Point = p1.max(p2) ;
trace(p3) ; // [Point:{100,100}]
Parameters
p:Point — The Point passed in this method
|
Point —
The new Point with the maximum horizontal coordinate and the maximum vertical coordinate.
|
| min | () | method |
public function min(p:Point):PointReturns a new Point with the minimum horizontal coordinate and the minimize vertical coordinate.
Example :
var p1:Point = new Point(10,100) ;
var p2:Point = new Point(100,10) ;
var p3:Point = p1.min(p2) ;
trace(p3) ; // [Point:{10,10}]
Parameters
p:Point — The Point passed in this method
|
Point —
a new Point with the min horizontal coordinate and the minimize vertical coordinate.
|
| negate | () | method |
public function negate():voidSets this Point with negate coordinates.
Example :
var p:Point = new Point(10,20) ;
trace(p) ; // [Point:{10,20}]
p.negate() ;
trace(p) ; // [Point:{-10,-20}]
p.negate() ;
trace(p) ; // [Point:{10,20}]
| negateNew | () | method |
public function negateNew():PointReturns the new negate Point of this Point.
Example :
var p:Point = new Point(10,20) ;
var n:Point = p.negateNew() ;
trace(n) ; // [Point:{-10,-20}]
Returns
Point —
The new negate Point of this Point.
|
| normalize | () | method |
public function normalize(thickness:Number):voidScales the line segment between (0,0) and the current point to a set length.
Example :
var p:Point = new Point(0,5) ;
p.normalize() ;
trace(p) ; // [Point:{0,1}]
Parameters
thickness:Number — The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1).
|
— if a zero-length vector or a illegal NaN value is calculate in this method.
|
See also
| offset | () | method |
public function offset(dx:Number, dy:Number):voidOffsets 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.
Example :
var p:Point = new Point(10,10) ;
p.offset(10,10) ;
trace(p) ; // [Point:{20,20}]
Parameters
dx:Number — The amount by which to offset the horizontal coordinate, x.
|
|
dy:Number — The amount by which to offset the vertical coordinate, y.
|
| plus | () | method |
public function plus(p:*):voidAdds the coordinates of another point to the coordinates of this point.
Parametersp:* — athe point to be added. You can use an object with the properties x and y.
|
| plusNew | () | method |
public function plusNew(p:*):PointAdds the coordinates of another point to the coordinates of this point to create a new point.
Parametersp:* — athe point to be added. You can use an object with the properties x and y.
|
Point —
The new point.
|
| polar | () | method |
public static function polar(len:Number, angle:Number):PointConverts a pair of polar coordinates to a Cartesian point coordinate.
Example :
var polar:Point = Point.polar( 5, Math.atan(3/4) ) ;
trace(polar) ; // [Point:{4,3}]
Parameters
len:Number — The length coordinate of the polar pair.
|
|
angle:Number — The angle, in radians, of the polar pair.
|
Point —
The new Cartesian point.
|
| project | () | method |
public function project(p:Point):PointReturns the projection of a Point with the specified Point passed in argument.
Parametersp:Point — the Point to project with this current Point.
|
Point —
the new project Point.
|
| reset | () | method |
public function reset(x:Number, y:Number):void
Sets the horizontal and vertical coordinates of this Point.
If the x and the y parameters are NaN or null the x value is 0 and y value is 0.
x:Number |
|
y:Number |
| rotate | () | method |
public function rotate(angle:Number):voidRotates the Point with the specified angle in argument.
Parametersangle:Number — the Angle to rotate this Point.
|
| rotateNew | () | method |
public function rotateNew(angle:Number):Point
Rotates the Point with the specified angle in argument and creates a new Point.
angle:Number — the Angle to rotate this Point.
|
Point —
The rotate new Point.
|
| scaleNew | () | method |
public function scaleNew(n:Number):Point
Rotates the Point with the specified s value in argument and creates a new Point.
n:Number — the value to scale this Point.
|
Point —
The scale new Point.
|
| subtractNew | () | method |
public function subtractNew(p:Point):PointSubtracts the coordinates of another point from the coordinates of this point to create a new point.
Parametersp:Point — The point to be subtracted.
|
Point —
The new Point.
|
| swap | () | method |
public function swap(p:Point):voidSwap the horizontal and vertical coordinates of two Point objects.
Example :
var p1:Point = new Point(10,20) ;
var p2:Point = new Point(30,40) ;
trace(p1 + " / " + p2) ; // [Point:{10,20}] / [Point:{30,40}]
p1.swap(p2) ;
trace(p1 + " / " + p2) ; // [Point:{30,40}] / [Point:{10,20}]
Parameters
p:Point |
| toSource | () | method |
public override function toSource(indent:int = 0):StringReturns a Eden represensation of the object.
Parametersindent:int (default = 0) |
String — a string representing the source code of the object.
|