za.co.luma.geom
Class Vector2DDouble
java.lang.Object
java.awt.geom.Point2D
za.co.luma.geom.Vector2DDouble
- All Implemented Interfaces:
- java.lang.Cloneable
- Direct Known Subclasses:
- PoissonDiskMultiSampler.Circle
public class Vector2DDouble
- extends java.awt.geom.Point2D
Class that represents a 2D vector over real numbers.
- Author:
- Herman Tulleken (herman@luma.co.za)
Nested classes/interfaces inherited from class java.awt.geom.Point2D |
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float |
Field Summary |
double |
x
|
double |
y
|
Method Summary |
static Vector2DDouble |
add(Vector2DDouble p1,
Vector2DDouble p2)
|
double |
angle()
|
static double |
distance(Vector2DDouble p1,
Vector2DDouble p2)
Returns the Euclidean distance between two points. |
static Vector2DDouble |
getPointBetween(Vector2DDouble p1,
Vector2DDouble p2,
double r)
|
double |
getX()
|
double |
getY()
|
static Vector2DDouble |
minus(Vector2DDouble p1,
Vector2DDouble p2)
|
static Vector2DDouble |
orthoUnit(Vector2DDouble p)
|
static boolean |
pointInTriangle(Vector2DDouble p,
Vector2DDouble a,
Vector2DDouble b,
Vector2DDouble c)
Checks whether a point lies within the triangle described by three vertices. |
static boolean |
sameSide(Vector2DDouble p1,
Vector2DDouble p2,
Vector2DDouble a,
Vector2DDouble b)
Checks whether a and b lies on the same side of line p1-p2, or not. |
static double |
scalarCross(Vector2DDouble p1,
Vector2DDouble p2)
Returns the z-coordinate of the cross product of two points
(embedded in 3D space). |
void |
scale(double r)
|
static Vector2DDouble |
scale(Vector2DDouble p,
double r)
|
void |
setAngle(double angleInRad)
|
void |
setLocation(double x,
double y)
|
void |
setSize(double size)
|
double |
size()
|
static double |
size(Vector2DDouble p)
|
static Vector2DDouble |
subtract(Vector2DDouble p1,
Vector2DDouble p2)
|
java.lang.String |
toString()
|
static Vector2DDouble |
unit(Vector2DDouble p1)
|
Vector2DDouble |
unitVector()
|
Methods inherited from class java.awt.geom.Point2D |
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
x
public double x
y
public double y
Vector2DDouble
public Vector2DDouble(double x,
double y)
getX
public double getX()
- Specified by:
getX
in class java.awt.geom.Point2D
getY
public double getY()
- Specified by:
getY
in class java.awt.geom.Point2D
setLocation
public void setLocation(double x,
double y)
- Specified by:
setLocation
in class java.awt.geom.Point2D
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
size
public double size()
scale
public void scale(double r)
unitVector
public Vector2DDouble unitVector()
distance
public static double distance(Vector2DDouble p1,
Vector2DDouble p2)
- Returns the Euclidean distance between two points.
- Returns:
scalarCross
public static double scalarCross(Vector2DDouble p1,
Vector2DDouble p2)
- Returns the z-coordinate of the cross product of two points
(embedded in 3D space).
sameSide
public static boolean sameSide(Vector2DDouble p1,
Vector2DDouble p2,
Vector2DDouble a,
Vector2DDouble b)
- Checks whether a and b lies on the same side of line p1-p2, or not.
If either or both points lie on the line, the method returns true.
pointInTriangle
public static boolean pointInTriangle(Vector2DDouble p,
Vector2DDouble a,
Vector2DDouble b,
Vector2DDouble c)
- Checks whether a point lies within the triangle described by three vertices.
- Parameters:
p
- The point.a
- One vertice of the triangle.b
- One vertice of the triangle.c
- One vertice of the triangle.
- Returns:
- True if the point lies within the triangle, false otherwise.
minus
public static Vector2DDouble minus(Vector2DDouble p1,
Vector2DDouble p2)
add
public static Vector2DDouble add(Vector2DDouble p1,
Vector2DDouble p2)
getPointBetween
public static Vector2DDouble getPointBetween(Vector2DDouble p1,
Vector2DDouble p2,
double r)
orthoUnit
public static Vector2DDouble orthoUnit(Vector2DDouble p)
scale
public static Vector2DDouble scale(Vector2DDouble p,
double r)
size
public static double size(Vector2DDouble p)
subtract
public static Vector2DDouble subtract(Vector2DDouble p1,
Vector2DDouble p2)
unit
public static Vector2DDouble unit(Vector2DDouble p1)
setSize
public void setSize(double size)
setAngle
public void setAngle(double angleInRad)
angle
public double angle()