public class ExtendedVector2d extends Vector2d
This definition of vector is often used in QuimP for expressing points as well
Constructor and Description |
---|
ExtendedVector2d()
Constructs and initializes a Vector2d to (0,0).
|
ExtendedVector2d(double[] v)
Constructs and initializes a Vector2d from the specified array.
|
ExtendedVector2d(double xx,
double yy)
Simple constructor.
|
ExtendedVector2d(Tuple2d t1)
Constructs and initializes a Vector2d from the specified Tuple.
|
ExtendedVector2d(Tuple2f t1)
Constructs and initializes a Vector2d from the specified Tuple.
|
ExtendedVector2d(Vector2d v1)
Constructs and initializes a Vector2d from the specified Vector.
|
ExtendedVector2d(Vector2f v1)
Constructs and initializes a Vector2d from the specified Vector.
|
Modifier and Type | Method and Description |
---|---|
void |
addVec(ExtendedVector2d v)
Add vector to this.
|
static double |
angle(ExtendedVector2d aa,
ExtendedVector2d bb)
Calculate angle between 2 vectors.
|
static double |
angleNonRelative(ExtendedVector2d aa,
ExtendedVector2d bb)
Calculate non relative angle between 2 vectors.
|
static double |
distPoinToInfLine(ExtendedVector2d p,
ExtendedVector2d a,
ExtendedVector2d b)
Calculate distance of point to line given as two points.
|
static double |
distPointToSegment(ExtendedVector2d p,
ExtendedVector2d s0,
ExtendedVector2d s1)
Compute distance between closest point and segment.
|
static double |
dot(ExtendedVector2d a,
ExtendedVector2d b)
Compute scalar dot.
|
static double |
lengthP2P(ExtendedVector2d a,
ExtendedVector2d b)
Get length of the vector between points.
|
static ExtendedVector2d |
lineIntersectionOLD(ExtendedVector2d na1,
ExtendedVector2d na2,
ExtendedVector2d nb1,
ExtendedVector2d nb2)
Deprecated.
Actually not used in this version of QuimP
|
static ExtendedVector2d |
lineIntersectionOLD2(ExtendedVector2d na1,
ExtendedVector2d na2,
ExtendedVector2d nb1,
ExtendedVector2d nb2)
Deprecated.
Actually not used in this version of QuimP
|
static List<Double> |
linspace(double start,
double end,
int numPoints)
Generate linearly distributed doubles between a;b including a and b.
|
void |
makeUnit()
Make versor from vector.
|
void |
multiply(double d)
Multiply this vector.
|
static ExtendedVector2d |
pointToSegment(ExtendedVector2d p,
ExtendedVector2d s0,
ExtendedVector2d s1)
Calculate the closest point on a segment to point P.
|
void |
power(double p)
Power this vector.
|
static int |
segmentIntersection(double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double[] intersection)
Compute the intersection between two line segments, or two lines of infinite length.
|
void |
setXY(double nx,
double ny)
Set vector coordinates.
|
static double |
triangleArea(ExtendedVector2d a,
ExtendedVector2d b,
ExtendedVector2d c)
Compute area of triangle (can be negative).
|
static ExtendedVector2d |
unitVector(ExtendedVector2d a,
ExtendedVector2d b)
Unit vector to target.
|
static ExtendedVector2d |
vecP2P(ExtendedVector2d a,
ExtendedVector2d b)
Create vector between points.
|
angle, dot, length, lengthSquared, normalize, normalize
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, clone, epsilonEquals, equals, equals, get, getX, getY, hashCode, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, set, set, set, set, setX, setY, sub, sub, toString
public ExtendedVector2d(double[] v)
v
- initial arraypublic ExtendedVector2d(Tuple2d t1)
t1
- initial Tuplepublic ExtendedVector2d(Tuple2f t1)
t1
- initial Tuplepublic ExtendedVector2d(Vector2d v1)
v1
- initial vestorpublic ExtendedVector2d(Vector2f v1)
v1
- initial vestorpublic ExtendedVector2d()
public ExtendedVector2d(double xx, double yy)
Creates vector mounted at (0,0).
xx
- \c x coordinate of vectoryy
- \c y coordinate of vectorpublic void makeUnit()
public void setXY(double nx, double ny)
nx
- x coordinateny
- y coordinatepublic void addVec(ExtendedVector2d v)
v
- vectorpublic void multiply(double d)
d
- multiplierpublic void power(double p)
p
- powerpublic static ExtendedVector2d unitVector(ExtendedVector2d a, ExtendedVector2d b)
a
- ab
- bpublic static List<Double> linspace(double start, double end, int numPoints)
start
- start valueend
- end valuenumPoints
- number of pointspublic static ExtendedVector2d vecP2P(ExtendedVector2d a, ExtendedVector2d b)
a
- start pointb
- end pointpublic static double lengthP2P(ExtendedVector2d a, ExtendedVector2d b)
a
- initial pointb
- end pointpublic static ExtendedVector2d lineIntersectionOLD(ExtendedVector2d na1, ExtendedVector2d na2, ExtendedVector2d nb1, ExtendedVector2d nb2)
na1
- initial point of A edgena2
- terminal point of A edgenb1
- initial point of B edgenb2
- terminal point of B edgepublic static ExtendedVector2d lineIntersectionOLD2(ExtendedVector2d na1, ExtendedVector2d na2, ExtendedVector2d nb1, ExtendedVector2d nb2)
na1
- initial point of A edgena2
- terminal point of A edgenb1
- initial point of B edgenb2
- terminal point of B edgepublic static int segmentIntersection(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double[] intersection)
x0
- X coordinate first end point first line segment.y0
- Y coordinate first end point first line segment.x1
- X coordinate second end point first line segment.y1
- Y coordinate second end point first line segment.x2
- X coordinate first end point second line segment.y2
- Y coordinate first end point second line segment.x3
- X coordinate second end point second line segment.y3
- Y coordinate second end point second line segment.intersection
- Preallocated by caller to double[2]public static double triangleArea(ExtendedVector2d a, ExtendedVector2d b, ExtendedVector2d c)
a
- a pointb
- b pointc
- c pointpublic static ExtendedVector2d pointToSegment(ExtendedVector2d p, ExtendedVector2d s0, ExtendedVector2d s1)
p
- point to tests0
- first point of segments1
- last point of segmentpublic static double distPointToSegment(ExtendedVector2d p, ExtendedVector2d s0, ExtendedVector2d s1)
p
- point to tests0
- first point of segments1
- last point of segmentpublic static double dot(ExtendedVector2d a, ExtendedVector2d b)
a
- left operandb
- right operandpublic static double angleNonRelative(ExtendedVector2d aa, ExtendedVector2d bb)
aa
- vectorbb
- vectorpublic static double angle(ExtendedVector2d aa, ExtendedVector2d bb)
aa
- vectorbb
- vectorpublic static double distPoinToInfLine(ExtendedVector2d p, ExtendedVector2d a, ExtendedVector2d b)
p
- point to testa
- line pointb
- line pointCopyright © 2002–2019 Department of Computer Science, Warwick University. All rights reserved.