public class Vector3D extends Object
| Constructor and Description |
|---|
Vector3D(Coordinate v)
Creates a new 3D vector from a
Coordinate. |
Vector3D(Coordinate from,
Coordinate to)
Creates a new vector with the direction and magnitude
of the difference between the
to and from
Coordinates. |
Vector3D(double x,
double y,
double z)
Creates a vector with the givne components.
|
| Modifier and Type | Method and Description |
|---|---|
Vector3D |
add(Vector3D v)
Computes a vector which is the sum
of this vector and the given vector.
|
static Vector3D |
create(Coordinate coord)
Creates a vector from a 3D
Coordinate. |
static Vector3D |
create(double x,
double y,
double z)
Creates a new vector with given X, Y and Z components.
|
Vector3D |
divide(double d)
Creates a new vector which has the same direction
and with length equals to the length of this vector
divided by the scalar value
d. |
static double |
dot(Coordinate v1,
Coordinate v2)
Computes the 3D dot-product of two
Coordinates. |
static double |
dot(Coordinate A,
Coordinate B,
Coordinate C,
Coordinate D)
Computes the dot product of the 3D vectors AB and CD.
|
double |
dot(Vector3D v)
Computes the dot-product of two vectors
|
boolean |
equals(Object o)
Tests if a vector o has the same values for the components.
|
double |
getX()
Gets the X component of this vector.
|
double |
getY()
Gets the Y component of this vector.
|
double |
getZ()
Gets the Z component of this vector.
|
int |
hashCode()
Gets a hashcode for this vector.
|
double |
length()
Computes the length of this vector.
|
static double |
length(Coordinate v)
Computes the length of a vector.
|
Vector3D |
normalize()
Computes a vector having identical direction
but normalized to have length 1.
|
static Coordinate |
normalize(Coordinate v)
Computes a vector having identical direction
but normalized to have length 1.
|
Vector3D |
subtract(Vector3D v)
Computes a vector which is the difference
of this vector and the given vector.
|
String |
toString()
Gets a string representation of this vector
|
public Vector3D(Coordinate v)
Coordinate. The coordinate should have
the X,Y and Z ordinates specified.v - the Coordinate to copypublic Vector3D(Coordinate from, Coordinate to)
Coordinates.from - the origin Coordinateto - the destination Coordinatepublic Vector3D(double x,
double y,
double z)
x - the X componenty - the Y componentz - the Z componentpublic static double dot(Coordinate A, Coordinate B, Coordinate C, Coordinate D)
A - the start point of the first vectorB - the end point of the first vectorC - the start point of the second vectorD - the end point of the second vectorpublic static Vector3D create(double x, double y, double z)
x - the X componenty - the Y componentz - the Z componentpublic static Vector3D create(Coordinate coord)
Coordinate.
The coordinate should have the
X,Y and Z ordinates specified.coord - the Coordinate to copypublic static double dot(Coordinate v1, Coordinate v2)
Coordinates.v1 - the first vectorv2 - the second vectorpublic double getX()
public double getY()
public double getZ()
public Vector3D add(Vector3D v)
v - the vector to addvpublic Vector3D subtract(Vector3D v)
v - the vector to subtractvpublic Vector3D divide(double d)
d.d - the scalar divisorpublic double dot(Vector3D v)
v - a vectorpublic double length()
public static double length(Coordinate v)
v - a coordinate representing a 3D vectorpublic Vector3D normalize()
public static Coordinate normalize(Coordinate v)
v - a coordinate representing a 3D vectorpublic String toString()
public boolean equals(Object o)
Copyright © 2024. All rights reserved.