Package org.eclipse.mosaic.lib.math
Class Vector3d
java.lang.Object
org.eclipse.mosaic.lib.math.Vector3d
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PointCloud.Point,SpatialObject
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCoordinate-wise addition of twovectors.Coordinate-wise addition of twovectors, storing the addition-result into a given vector.doubleCalculates and returns the angle between the current and the given vector in radians.The cross-product of twoVector3d, storing the subtraction-result into a given vector.doubleMethod to determine the sqquared Euclidean distance between the two points represented by twoVector3ds, resulting in a scalar value.doubleMethod to determine the Euclidean distance between the two points represented by twoVector3ds, resulting in a scalar value.doubleThe dot product of twoVector3dresulting in a scalar.booleaninthashCode()booleanisFuzzyEqual(Vector3d other) Equal-check for twoVector3dsusingMathUtils.isFuzzyEqual(double, double).doubledoublemultiply(double f) Multiplies a scalar to theVector3d.Multiplies a scalar to aVector3d, storing the multiplication-result into a given vector.norm()Normalizes theVector3dby dividing it by itsmagnitude().Normalizes theVector3dby dividing it by itsmagnitude(), storing the result into a given vector.rotate(double angle, double axisX, double axisY, double axisZ) Rotates thisVector3dby the specified angle (in radians) around the given axis.Rotates thisVector3dby the specified angle (in radians) around the given axis.Rotates thisVector3dby the specified angle (in degrees) around the given axis.Coordinate-wise multiplication of twovectors.Coordinate-wise multiplication of twovectors, storing the scale-result into a given vector.set(double f) Sets all entries of theVector3dto the given value.set(double x, double y, double z) Sets the coordinates of theVector3dto the given values.Coordinate-wise subtraction of twovectors.Coordinate-wise subtraction of twovectors, storing the subtraction-result into a given vector.voidtoArray(double[] result, int offset) Writes theVector3dto an array using doubles, given an offset as start-index.voidtoArray(float[] result, int offset) Writes theVector3dto an array using floats, given an offset as start-index.Conversion ofVector3dto aCartesianPointwithin MOSAIC's coordinate system.toCartesian(MutableCartesianPoint result) Conversion ofVector3dto aCartesianPointwithin MOSAIC's coordinate system, storing the results in a givenMutableCartesianPoint.toGeo()toGeo(MutableGeoPoint result) Projection ofVector3dto aGeoPointusing the underlyingGeoProjection, storing the result in a givenMutableGeoPoint.toString()
-
Field Details
-
x
public double x -
y
public double y -
z
public double z
-
-
Constructor Details
-
Vector3d
public Vector3d()Constructor forVector3d, which initializes it as V_0.|0| v = |0| |0| -
Vector3d
public Vector3d(double x, double y, double z) Constructor forVector3d, initializing it with the given coordinates.|x| v = |y| |z|- Parameters:
x- X-Coordinatey- Y-Coordinatez- Z-Coordinate
-
Vector3d
Constructor forVector3d, initializing it with a copy of the coordinates from another givenVector3d.Vector3d(v_j): |x_j| v = |y_j| |z_j|- Parameters:
v-Vector3dto be copied
-
-
Method Details
-
set
Sets the coordinates of theVector3dto the given value, setting it to a copy of the coordinates from another givenVector3d.- Parameters:
v-Vector3dto be copied- Returns:
- the vector on which
sethas been called
-
set
Sets the coordinates of theVector3dto the given values.- Parameters:
x- X-Coordinatey- Y-Coordinatez- Z-Coordinate- Returns:
- the vector on which
sethas been called
-
set
Sets all entries of theVector3dto the given value.- Parameters:
f- given value- Returns:
- the vector on which
sethas been called
-
multiply
Multiplies a scalar to theVector3d.v_i.multiply(f): x_i = x_i * f y_i = y_i * f z_i = z_i * f- Parameters:
f- scalar of type double- Returns:
- the vector on which
multiplyhas been called
-
multiply
Multiplies a scalar to aVector3d, storing the multiplication-result into a given vector.v_i.multiply(f, v_r): x_r = x_i * f y_r = y_i * f z_r = z_i * f- Parameters:
f- scalar of type doubleresult- theVector3dwhere the multiplication result should be saved to- Returns:
- the result-vector
-
scale
Coordinate-wise multiplication of twovectors.v_i.scale(v_j): x_i = x_i * x_j y_i = y_i * y_j z_i = z_i * z_j- Parameters:
scale- theVector3dto be scaled with- Returns:
- the vector on which
scalehas been called
-
scale
Coordinate-wise multiplication of twovectors, storing the scale-result into a given vector.v_i.scale(v_j, v_r): x_r = x_i * x_j y_r = y_i * y_j z_r = z_i * z_j -
add
Coordinate-wise addition of twovectors.v_i.add(v_j): x_i = x_i + x_j y_i = y_i + y_j z_i = z_i + z_j- Parameters:
v- theVector3dto be added- Returns:
- the vector on which
addhas been called
-
add
Coordinate-wise addition of twovectors, storing the addition-result into a given vector.v_i.add(v_j, v_r): x_r = x_i + x_j y_r = y_i + y_j z_r = z_i + z_j -
subtract
Coordinate-wise subtraction of twovectors.v_i.subtract(v_j): x_i = x_i - x_j y_i = y_i - y_j z_i = z_i - z_j- Parameters:
v- theVector3dto be subtracted- Returns:
- the vector on which
subtracthas been called
-
subtract
Coordinate-wise subtraction of twovectors, storing the subtraction-result into a given vector.v_i.subtract(v_j, v_r): x_r = x_i - x_j y_r = y_i - y_j z_r = z_i - z_j -
dot
The dot product of twoVector3dresulting in a scalar.v_i.dot(v_j): = x_i * x_j + y_i * y_j + z_i * z_j
- Parameters:
v- theVector3dto be used for the dot product- Returns:
- the resulting scalar
-
cross
The cross-product of twoVector3d, storing the subtraction-result into a given vector.v_i.cross(v_j, v_r): x_r = y_i * z_j - z_i * y_j y_r = z_i * x_j - x_i * z_j z_r = x_i * y_j - y_i * x_j -
angle
Calculates and returns the angle between the current and the given vector in radians.- Parameters:
v- the given vector- Returns:
- angle in radians
-
norm
Normalizes theVector3dby dividing it by itsmagnitude().- Returns:
- the normalized
Vector3d
-
norm
Normalizes theVector3dby dividing it by itsmagnitude(), storing the result into a given vector. -
magnitude
public double magnitude() -
magnitudeSqr
public double magnitudeSqr() -
distanceTo
Method to determine the Euclidean distance between the two points represented by twoVector3ds, resulting in a scalar value.v_i.distanceTo(v_j) = sqrt((x_j - x_i)^2 + (y_j - y_i)^2 + (z_j - z_i)^2)
- Parameters:
v- theVector3dto which the distance should be determined- Returns:
- the resulting Euclidean distance
-
distanceSqrTo
Method to determine the sqquared Euclidean distance between the two points represented by twoVector3ds, resulting in a scalar value.v_i.distanceSqrTo(v_j) = (x_j - x_i)^2 + (y_j - y_i)^2 + (z_j - z_i)^2
- Parameters:
v- theVector3dto which the squared distance should be determined- Returns:
- the resulting squared Euclidean distance
-
rotateDeg
Rotates thisVector3dby the specified angle (in degrees) around the given axis.- Parameters:
angleDeg- Rotation angle in degreesaxis- Rotation axis- Returns:
- the rotated
Vector3d
-
rotate
Rotates thisVector3dby the specified angle (in radians) around the given axis.- Parameters:
angle- Rotation angle in radiansaxis- Rotation axis- Returns:
- the rotated
Vector3d
-
rotate
Rotates thisVector3dby the specified angle (in radians) around the given axis.- Parameters:
angle- Rotation angle in radiansaxisX- Rotation axis x-componentaxisY- Rotation axis y-componentaxisZ- Rotation axis z-component- Returns:
- the rotated
Vector3d
-
toArray
public void toArray(double[] result, int offset) Writes theVector3dto an array using doubles, given an offset as start-index.- Parameters:
result- the array where the result should be saved tooffset- the start-index for writing
-
toArray
public void toArray(float[] result, int offset) Writes theVector3dto an array using floats, given an offset as start-index.- Parameters:
result- the array where the result should be saved tooffset- the start-index for writing
-
toCartesian
Conversion ofVector3dto aCartesianPointwithin MOSAIC's coordinate system.- Returns:
- the resulting
CartesianPoint
-
toCartesian
Conversion ofVector3dto aCartesianPointwithin MOSAIC's coordinate system, storing the results in a givenMutableCartesianPoint.- Parameters:
result- aMutableCartesianPointwhere the conversion will be saved to- Returns:
- the resulting
CartesianPoint
-
toGeo
- Returns:
- the resulting
GeoPoint
-
toGeo
Projection ofVector3dto aGeoPointusing the underlyingGeoProjection, storing the result in a givenMutableGeoPoint.- Parameters:
result- theMutableGeoPointwhere the projection will be saved to- Returns:
- the resulting
MutableGeoPoint
-
isFuzzyEqual
Equal-check for twoVector3dsusingMathUtils.isFuzzyEqual(double, double). -
equals
-
hashCode
public int hashCode() -
toString
-