|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.azalient.apo.basics.Xyz
public class Xyz
A utility class for representing a point in three-dimensional space, or a three-dimensional vector.
This class has methods for vector arithmetic (add, subtract) and also for cross product and dot product.
| Field Summary | |
|---|---|
static IXyz |
NORTH
|
static IXyz |
UNITY
|
static IXyz |
ZERO
|
| Fields inherited from interface com.azalient.api.a.position.IXyz |
|---|
ZERO_ARRAY |
| Constructor Summary | |
|---|---|
Xyz()
Create a new point or vector (0,0,0) |
|
Xyz(double px,
double py,
double pz)
Create a new point or vector (px, py, pz) |
|
Xyz(IPosition that)
Create a new object point or vector as a copy of that IPosition |
|
Xyz(IXyz that)
Create a new object point or vector as a copy of that |
|
Xyz(IXyz v,
char op,
double s)
Create a new object equal to the scalar operation of v by s. |
|
Xyz(IXyz u,
char op,
IXyz v)
Create a new object calculated from operation on two vectors. |
|
Xyz(IXyz p,
double distanceXY,
IAngle bearing,
double gradientFrac)
Create a new point given a start point, an XY-plane distance r, bearing in radians and fractional gradient |
|
Xyz(IXyz a,
IXyz b)
Create a new Xyz that represents the vector A to B |
|
Xyz(IXyz p,
IXyz q,
double r)
If this point is P, create a point on line PQ at relative distance r, where r == 0 is at P, r == 1 is at Q. |
|
| Method Summary | |
|---|---|
void |
abZ(IXyz a,
IXyz b)
Adjust the height of this point to be on the plane that connects A and B such that a line drawn perpendicular to AB in the plane has constant Z |
void |
add(IXyz v)
Vector add operation in place. |
IAngle |
angleBetween(IXyz v)
Returns the UNSIGNED angle in between this vector and the vector parameter; the return value is constrained to the range [0,180]. |
IAngle |
asBearing()
Return bearing CW from N in the range [0, 2PI) |
double[] |
asDouble3()
Returns this point/vector as an array of 3 doubles |
double |
asGradient()
Return the fractional gradient component of this vector |
boolean |
atZERO()
Returns true if this point is at the origin (all zeroes) |
IAngle |
bearingTo(IXyz there)
Radians in the range [0, 2PI) |
IXyz |
copy()
Return a new object as a copy of this point/vector |
IXyz |
cross(IXyz v)
Return new vector result of cross with v, original vectors unchanged. |
void |
crossWith(IXyz v)
Vector cross operation in place. |
double |
distance(IXy there)
Returns the distance from here to there |
double |
distance(IXyz there)
Returns the distance from here to there |
double |
distance(IXyz a,
IXyz b,
boolean limitAB)
return the distance from "this" to line segment AB |
void |
divide(double s)
Scalar divide, in place |
IXyz |
dividedBy(double s)
Divide all components of Vector by given scalar, returning new vector, originals unchanged. |
double |
dot(IXyz v)
Computes the dot product of this vector and vector V. |
double |
gradientToFrac(IXyz there)
Fractional gradient as dh/XY |
static IXy |
intersectionPoint(IXy p1,
IXy p2,
IXy p3,
IXy p4,
boolean forSegments)
calculate the intersection point of line P1P2 with P3P4. |
boolean |
isFinite()
Test if all components are finite and numbers (not NaN) |
double |
length()
Returns the length of this vector (or the distance of the point from the origin). |
double |
lengthSquared()
|
IXyz |
minus(IXyz v)
Vector minus, returning new vector, originals unchanged. |
IXyz |
multipliedBy(double s)
Multiply all components of Vector by given scalar, returning new vector, originals unchanged. |
void |
multiply(double s)
Scalar multiply, in place |
IXyz |
nearestPointOn(IXyz a,
IXyz b,
boolean limitAB)
return the nearest point to "this" on line segment AB. |
IXyz |
nearestPointOnLine(IXyz a,
IXyz b)
Returns the nearest point on line AB to this point. |
void |
negate()
Negates the value of this xyz in place. |
IXyz |
negative()
Return a negative of this vector, original unchanged |
IXyz |
normalized()
Returns normalized version of this vector, original unchanged. |
IXyz |
parallelComponent(IXyz v)
Return the component of v that is parallel with this |
double |
parallelComponentMag(IXyz v)
Return the magnitude of the component of v that is parallel with this |
IXyz |
perpComponent(IXyz v)
The component of v that is perpendicular to this |
IXyz |
plus(IXyz v)
Vector plus, returning new vector, originals unchanged. |
int |
rgb()
Convert a triple that represents a color into an RGB encoded integer |
void |
rotate(IXya xya)
Rotate this point in the XY-plane around the axis of rotation (x,y) by given angle. |
void |
rotate(IXy xy,
IAngle rotation)
Rotate this point in the XY-plane around the axis of rotation (x,y) by given angle. |
IXyz |
rotationAsMove(IXya xya)
Convert the given XY-plane rotation around an XY-axis into a translation |
IXyz |
rotationAsMove(IXy xy,
IAngle rotation)
Convert the given XY-plane rotation around an XY-axis into a translation |
void |
scale(double s)
Scalar multiply, in place |
Xyz |
selfNormalize()
Normalizes this vector in place. |
void |
set(double px,
double py,
double pz)
Set this point/vector to the given values |
void |
set(IXyz xyz)
Set this point/vector to have the same values as that one (copy by value, not by reference) |
void |
set(IXyz p,
double distanceXY,
IAngle bearing,
double gradientFrac)
Set the location based on a start point, an XY-plane distance r, bearing in radians and fractional gradient |
void |
subtract(IXyz v)
Vector subtract operation in place. |
boolean |
toRightOf(IXyz pA,
IXyz pB)
Is this point to the right of the line segment AB? If this point is T, calculate cross product of vectors AT and AB. |
String |
toString()
|
IXyz |
transform(IXyz origin0,
IAngle compass0,
IXyz origin1,
IAngle compass1)
|
Xyz |
truncateLength(double maxLength)
Clip to a given length, returning a new object if modification is required |
double |
v(int i)
indexed access to components: i=0 -> X i=1 -> Y i=2 -> Z |
void |
v(int i,
double v)
indexed access to components: i=0 -> X i=1 -> Y i=2 -> Z |
double |
x()
X-coordinate of this point |
void |
x(double _x)
Set the X-coordinate of this point |
double |
y()
Y-coordinate of this point |
void |
y(double _y)
Set the Y-coordinate of this point |
double |
z()
Z-coordinate of this point |
void |
z(double _z)
Set the Z-coordinate of this point |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final IXyz ZERO
public static final IXyz NORTH
public static final IXyz UNITY
| Constructor Detail |
|---|
public Xyz()
public Xyz(double px,
double py,
double pz)
public Xyz(IXyz that)
public Xyz(IPosition that)
public Xyz(IXyz a,
IXyz b)
public Xyz(IXyz u,
char op,
IXyz v)
u - the first xyzop - operand either '+', '-' or 'x'. 'x' means cross product: a vector that is perpendicular to both u and vv - the second xyz
public Xyz(IXyz v,
char op,
double s)
s - the scalar valueop - operand either '*' or '/'v - the source xyz
public Xyz(IXyz p,
double distanceXY,
IAngle bearing,
double gradientFrac)
public Xyz(IXyz p,
IXyz q,
double r)
| Method Detail |
|---|
public final IXyz copy()
IXyz
copy in interface IXyzpublic final boolean atZERO()
IXyz
atZERO in interface IXyzpublic final double v(int i)
IXyz
v in interface IXyz
public final void v(int i,
double v)
IXyz
v in interface IXyzpublic final IAngle asBearing()
IXyz
asBearing in interface IXyzpublic final void x(double _x)
IXyz
x in interface IXyx in interface IXyzpublic final void y(double _y)
IXyz
y in interface IXyy in interface IXyzpublic final void z(double _z)
IXyz
z in interface IXyzpublic final double length()
IXyz
length in interface IXyzpublic final double x()
IXyz
x in interface IXyx in interface IXyzx in interface OpenGLXyzpublic final double y()
IXyz
y in interface IXyy in interface IXyzy in interface OpenGLXyzpublic final double z()
IXyz
z in interface IXyzz in interface OpenGLXyzpublic void set(IXyz xyz)
IXyz
set in interface IXyz
public final void set(double px,
double py,
double pz)
IXyz
set in interface IXyz
public final void set(IXyz p,
double distanceXY,
IAngle bearing,
double gradientFrac)
public final void negate()
negate in interface IXyzpublic final IXyz negative()
IXyz
negative in interface IXyzpublic final IXyz normalized()
IXyz
normalized in interface IXyzpublic final Xyz selfNormalize()
selfNormalize in interface IXyzpublic final double distance(IXyz there)
distance in interface IXyzthere - public final double distance(IXy there)
distance in interface IXythere - public final IAngle bearingTo(IXyz there)
bearingTo in interface IXyzpublic final double gradientToFrac(IXyz there)
gradientToFrac in interface IXyzpublic final double asGradient()
IXyz
asGradient in interface IXyzpublic final void add(IXyz v)
IXyz
add in interface IXyzpublic final void subtract(IXyz v)
IXyz
subtract in interface IXyzpublic final IXyz plus(IXyz v)
plus in interface IXyzpublic final IXyz minus(IXyz v)
minus in interface IXyzpublic final void crossWith(IXyz v)
crossWith in interface IXyzpublic final IXyz cross(IXyz v)
IXyz
cross in interface IXyzpublic final void scale(double s)
IXyz
scale in interface IXyzpublic final void divide(double s)
IXyz
divide in interface IXyzpublic final void multiply(double s)
IXyz
multiply in interface IXyzpublic final IXyz multipliedBy(double s)
IXyz
multipliedBy in interface IXyzpublic final IXyz dividedBy(double s)
IXyz
dividedBy in interface IXyzpublic final double dot(IXyz v)
U.V = u * v * cos(theta)
= ux*vx + uy*vy + uz*vz
where u is the length of U, v is the length of V and theta is the angle
between U and V. As this returns a scalar value,it cannot be included in
the constructors or in the other vector operation methods
dot in interface IXyzv - the other vector
public final double lengthSquared()
lengthSquared in interface IXyzpublic final IXyz parallelComponent(IXyz v)
parallelComponent in interface IXyzpublic final double parallelComponentMag(IXyz v)
parallelComponentMag in interface IXyzpublic final IXyz perpComponent(IXyz v)
perpComponent in interface IXyzpublic final Xyz truncateLength(double maxLength)
truncateLength in interface IXyzpublic final IAngle angleBetween(IXyz v)
angleBetween in interface IXyzv - the other vector
public final int rgb()
public final boolean toRightOf(IXyz pA,
IXyz pB)
toRightOf in interface IXyzpublic String toString()
toString in class Object
public final IXyz nearestPointOnLine(IXyz a,
IXyz b)
nearestPointOnLine in interface IXyz
public final void rotate(IXy xy,
IAngle rotation)
rotate in interface IXyzpublic final void rotate(IXya xya)
rotate in interface IXyz
public final IXyz rotationAsMove(IXy xy,
IAngle rotation)
rotationAsMove in interface IXyzpublic final IXyz rotationAsMove(IXya xya)
rotationAsMove in interface IXyz
public final IXyz transform(IXyz origin0,
IAngle compass0,
IXyz origin1,
IAngle compass1)
transform in interface IXyz
public final IXyz nearestPointOn(IXyz a,
IXyz b,
boolean limitAB)
IXyz
nearestPointOn in interface IXyzlimitAB - if true, the point must be between A and B, inclusive
public final double distance(IXyz a,
IXyz b,
boolean limitAB)
IXyz
distance in interface IXyzlimitAB - if true, the distance is to a point between A and B, inclusive. If false,
the line is extended to infinite length
public static IXy intersectionPoint(IXy p1,
IXy p2,
IXy p3,
IXy p4,
boolean forSegments)
public final void abZ(IXyz a,
IXyz b)
abZ in interface IXyzpublic final boolean isFinite()
IXyz
isFinite in interface IXyzpublic final double[] asDouble3()
IXyz
asDouble3 in interface IXyz
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||