Class Point
<<<<<<< HEAD
Defined in: GameLib.js.
=======
Defined in: gamelib.js.
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
Constructor Attributes | Constructor Name and Description |
---|---|
Point(x, y)
Create a new point with given x and y coordinates.
|
Field Attributes | Field Name and Description |
---|---|
The x coordinate of this point.
|
|
The y coordinate of this point.
|
Method Attributes | Method Name and Description |
---|---|
add(other)
Adds a point to this one and returns the new point.
|
|
<static> |
Point.add(other)
|
<static> |
Point.cross(other)
|
cross(other)
Calculate the cross product of this point and another point (Vector).
|
|
<static> |
Point.direction(p1, p2)
If you have two dudes, one standing at point p1, and the other
standing at point p2, then this method will return the direction
that the dude standing at p1 will need to face to look at p2.
|
<static> |
Point.distance(p1, p2)
|
distance(other)
Computed the Euclidean between this point and another point.
|
|
<static> | <<<<<<< HEAD |
dot(other)
Calculate the dot product of this point and another point (Vector).
|
|
equal(other)
Determine whether this point is equal to another point.
|
|
<static> |
<<<<<<< HEAD
=======
Point.equal(other)
|
<static> |
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
Point.fromAngle(angle)
Construct a point on the unit circle for the given angle.
|
<static> |
Point.length()
|
length()
Computed the length of this point as though it were a vector from (0,0) to (x,y)
|
|
<static> |
Point.magnitude()
|
Calculate the magnitude of this Point (Vector).
|
|
norm()
The norm of a vector is the unit vector pointing in the same direction.
|
|
<static> |
Point.norm()
|
<static> |
Point.scale(scalar)
|
scale(scalar)
Scale this Point (Vector) by a constant amount.
|
|
subtract(other)
Subtracts a point to this one and returns the new point.
|
|
<static> |
Point.subtract(other)
|
Method Detail
{Point}
add(other)
Adds a point to this one and returns the new point.
- Parameters:
- {Point} other
- The point to add this point to.
- Returns:
- A new point, the sum of both.
<static>
Point.add(other)
- Parameters:
- other
<static>
Point.cross(other)
- Parameters:
- other
{Number}
cross(other)
<<<<<<< HEAD
Calculate the cross product of this point and another point (Vector).
Usually cross products are thought of as only applying to three dimensional vectors,
but z can be treated as zero. The result of this method is interpreted as the magnitude
=======
Calculate the cross product of this point and another point (Vector).
Usually cross products are thought of as only applying to three dimensional vectors,
but z can be treated as zero. The result of this method is interpreted as the magnitude
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
of the vector result of the cross product between [x1, y1, 0] x [x2, y2, 0]
perpendicular to the xy plane.
- Parameters:
- {Point} other
- The point to cross with this point.
- Returns:
- The cross product of this point with the other point as scalar value.
<static>
Point.direction(p1, p2)
If you have two dudes, one standing at point p1, and the other
standing at point p2, then this method will return the direction
that the dude standing at p1 will need to face to look at p2.
- Returns:
- The direction from p1 to p2 in radians.
=======
<static>
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
{Number}
<<<<<<< HEAD
distance(other)
Computed the Euclidean between this point and another point.
=======
Point.distance(p1, p2)
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
- Parameters:
- <<<<<<< HEAD {Point} other
- The point to compute the distance to. ======= {Point} p1
- {Point} p2 >>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
- Returns: <<<<<<< HEAD
- The distance between this point and another point. =======
- The Euclidean distance between two points. >>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
<static>
=======
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
=======
distance(other)
Computed the Euclidean between this point and another point.
>>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
- Parameters:
- <<<<<<< HEAD {Point} p1
- {Point} p2 ======= {Point} other
- The point to compute the distance to. >>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
- Returns: <<<<<<< HEAD
- The Euclidean distance between two points. =======
- The distance between this point and another point. >>>>>>> 3fe863faa00b8e51f1f2f53b6d3e10fbf4b349ff
<static>
Point.dot(other)
- Parameters:
- other
{Number}
dot(other)
Calculate the dot product of this point and another point (Vector).
- Parameters:
- {Point} other
- The point to dot with this point.
- Returns:
- The dot product of this point dot other as a scalar value.
{Boolean}
equal(other)
Determine whether this point is equal to another point.
- Parameters:
- {Point} other
- The point to check for equality.
- Returns:
- true if the other point has the same x, y coordinates, false otherwise.
<static>
Point.equal(other)
- Parameters:
- other
Construct a point on the unit circle for the given angle.
- Parameters:
- {Number} angle
- The angle in radians
- Returns:
- The point on the unit circle.
<static>
Point.length()
{Number}
length()
Computed the length of this point as though it were a vector from (0,0) to (x,y)
- Returns:
- The length of the vector from the origin to this point.
<static>
Point.magnitude()
{Number}
magnitude()
Calculate the magnitude of this Point (Vector).
- Returns:
- The magnitude of this point as if it were a vector from (0, 0) -> (x, y).
{Point}
norm()
The norm of a vector is the unit vector pointing in the same direction. This method
treats the point as though it is a vector from the origin to (x, y).
- Returns:
- The unit vector pointing in the same direction as this vector.
<static>
Point.norm()
<static>
Point.scale(scalar)
- Parameters:
- scalar
{Point}
scale(scalar)
Scale this Point (Vector) by a constant amount.
- Parameters:
- {Number} scalar
- The amount to scale this point by.
- Returns:
- A new point, this * scalar.
{Point}
subtract(other)
Subtracts a point to this one and returns the new point.
- Parameters:
- {Point} other
- The point to subtract from this point.
- Returns:
- A new point, this - other.
<static>
Point.subtract(other)
- Parameters:
- other