public class Vector3 extends Object implements EuclidConstants
Vectors and points are very closely related and some people use them interchangeably. A Point3 has a position and cannot be normalised. In very many routines, however, Vectors and Points can either be used interchangeably, or there are equivalent routines or they can be converted using cross-constructors. (They cannot be interconverted through casts).
The default vector is 0.0, 0.0, 0.0. Some operations on this will result in ZerolengthVector Exceptions.
| Modifier and Type | Field and Description |
|---|---|
static Vector3 |
XV
X axis
|
static Vector3 |
YV
Y axis
|
static Vector3 |
ZEROV
zero-length vector
|
static Vector3 |
ZV
Z axis
|
C_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
Vector3()
null constructor
|
Vector3(Axis.Axis3 axis)
axial unit vector constructor.
|
Vector3(double[] array)
construct from vector components.
|
Vector3(double x,
double y,
double z)
construct from vector components.
|
Vector3(Point3 p)
make a vector from a point vector is from origin to point
|
Vector3(RealArray f)
copy constructor from RealArray.
|
Vector3(Vector3 v)
copy constructor:
|
| Modifier and Type | Method and Description |
|---|---|
Vector3 |
clone(Point3 p)
from Point3 vector is from origin to point
|
Vector3 |
clone(Vector3 v)
copy constructor: synonym for copy constructor
|
Vector3 |
cross(Vector3 v3)
create cross product.
|
protected double |
dot(double[] v3)
dot product - protected
|
double |
dot(Vector3 v3)
create dot product.
|
double |
elementAt(int n)
get component.
|
Angle |
getAngleMadeWith(Vector3 v2)
calculate unsigned angle between vectors result = angle between this and
v2 uses acos(this.dot.v2) so angle is unsigned does not alter this.
|
double[] |
getArray()
get the vector components
|
double |
getLength()
return vector length.
|
Vector3 |
getNonColinearVector()
get any vector not colinear with this.
|
Vector3 |
getPerpendicularVector()
get any vector perpendicular to this.
|
double |
getScalarTripleProduct(Vector3 v2,
Vector3 v3)
calculate scalar triple product between vectors.
|
Vector3 |
getUnitVector()
get normalized vector.
|
boolean |
isColinearVector(Vector3 v)
are two vectors colinear.
|
boolean |
isEqualTo(Vector3 v)
are two vectors equal lengths.
|
boolean |
isIdenticalTo(Vector3 v)
are two vectors equal in all components.
|
boolean |
isZero()
is vector of zero length.
|
boolean |
longerThan(Vector3 v)
vector length > vector length
|
Vector3 |
multiplyBy(double f)
scalar multiplication.
|
void |
multiplyEquals(double f)
scalar multiplication.
|
Vector3 |
negative()
negative of vector.
|
Vector3 |
negativeEquals()
negative of vector.
|
Vector3 |
normalise()
Deprecated.
(use normalize())
|
Vector3 |
normalize()
normalize vector.
|
Vector3 |
plus(Vector3 v3)
vector addition.
|
void |
plusEquals(Vector3 v3)
vector addition.
|
Vector3 |
projectOnto(Vector3 v)
projection of this onto vector.
|
Vector3 |
round()
sets vector components to nearest integer value.
|
void |
setElementAt(int n,
double f)
set component.
|
Vector3 |
subtract(Vector3 v3)
vector subtraction.
|
void |
subtractEquals(Vector3 v3)
vector subtraction.
|
String |
toString()
get string representation.
|
Vector3 |
transform(Transform3 t)
create transformed vector.
|
public static final Vector3 ZEROV
public static final Vector3 XV
public static final Vector3 YV
public static final Vector3 ZV
public Vector3()
public Vector3(double x,
double y,
double z)
x - componenty - componentz - componentpublic Vector3(double[] array)
throws EuclidRuntimeException
array - componentsEuclidRuntimeExceptionpublic Vector3(Axis.Axis3 axis)
axis - to usepublic Vector3(Vector3 v)
v - vector to copypublic Vector3(RealArray f) throws EuclidRuntimeException
f - the array (of length 3)EuclidRuntimeExceptionpublic Vector3(Point3 p)
p - the pointpublic Vector3 clone(Vector3 v)
v - vector to copypublic Vector3 clone(Point3 p)
p - the pointpublic double[] getArray()
public boolean isEqualTo(Vector3 v)
v - public boolean longerThan(Vector3 v)
v - vector to comparepublic Vector3 multiplyBy(double f)
f - multiplier for all componentspublic void multiplyEquals(double f)
f - multiplier for all componentspublic Vector3 plus(Vector3 v3)
v3 - vector to addpublic void plusEquals(Vector3 v3)
v3 - vector to subtractpublic Vector3 subtract(Vector3 v3)
v3 - vector to subtractpublic void subtractEquals(Vector3 v3)
v3 - vector to subtractpublic Vector3 negative()
public Vector3 negativeEquals()
public double elementAt(int n)
throws EuclidRuntimeException
n - the zero-based indexEuclidRuntimeExceptionpublic void setElementAt(int n,
double f)
throws EuclidRuntimeException
n - the zero-based indexf - component valueEuclidRuntimeExceptionpublic boolean isIdenticalTo(Vector3 v)
v - public boolean isZero()
public Vector3 transform(Transform3 t)
t - transformpublic Vector3 cross(Vector3 v3)
v3 - vector to multiplypublic Vector3 round()
public Vector3 normalize()
public Vector3 normalise()
public Vector3 getUnitVector()
public double getLength()
public double dot(Vector3 v3)
v3 - vector to multiplyprotected double dot(double[] v3)
v3 - public Angle getAngleMadeWith(Vector3 v2)
v2 - vector to multiplypublic double getScalarTripleProduct(Vector3 v2, Vector3 v3)
v2 - vector to multiplyv3 - vector to multiplypublic Vector3 projectOnto(Vector3 v) throws EuclidRuntimeException
v - vector to project ontoEuclidRuntimeException - vector or this is zero lengthpublic boolean isColinearVector(Vector3 v)
v - vector to test with thispublic Vector3 getNonColinearVector()
public Vector3 getPerpendicularVector()
Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.