Package org.opentrafficsim.core.math
Class Speed3D
java.lang.Object
org.opentrafficsim.core.math.Speed3D
- All Implemented Interfaces:
java.io.Serializable
public class Speed3D
extends java.lang.Object
implements java.io.Serializable
A 3D speed vector, decomposed in X, Y, and Z-speed with easy conversion from and to a spherical coordinate system.
Physicists and mathematicians do not agree on the meaning of theta and phi. In this class the convention in the physics domain is used:
Physicists and mathematicians do not agree on the meaning of theta and phi. In this class the convention in the physics domain is used:
- theta is the angle from the z direction.
- phi is the projected angle in the xy-plane from the x direction.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description Speed3D(double x, double y, double z, SpeedUnit unit)
Construct a new Speed3D from three double Cartesian coordinates and a speed unit.Speed3D(Speed speed, Direction theta, Direction phi)
Construct a new Speed3D from a strongly typed speed and polar coordinates.Speed3D(Speed x, Speed y, Speed z)
Construct a new Speed3D from three strongly typed Cartesian coordinates.Speed3D(SpeedVector speed)
Construct a new Speed3D from vector of strongly typed Cartesian coordinates. -
Method Summary
Modifier and Type Method Description Direction
getPhi()
Retrieve the phi of this Speed3D.Speed
getSpeed()
Retrieve the norm of this Speed3D.Direction
getTheta()
Retrieve the theta of this Speed3D.Speed
getX()
Retrieve the x-component of this Speed3D.Speed
getY()
Retrieve the y-component of this Speed3D.Speed
getZ()
Retrieve the z-component of this Speed3D.java.lang.String
toString()
-
Constructor Details
-
Speed3D
Construct a new Speed3D from vector of strongly typed Cartesian coordinates.- Parameters:
speed
- SpeedVector; the speeds in 3D (YPR coded)- Throws:
ValueRuntimeException
- in case the vector does not have exactly three elements
-
Speed3D
Construct a new Speed3D from three strongly typed Cartesian coordinates.- Parameters:
x
- Speed; the speed in the x-directiony
- Speed; the speed in the y-directionz
- Speed; the speed in the z-direction- Throws:
ValueRuntimeException
- in case the units are incorrect
-
Speed3D
Construct a new Speed3D from three double Cartesian coordinates and a speed unit.- Parameters:
x
- double; the speed in the x-directiony
- double; the speed in the y-directionz
- double; the speed in the z-directionunit
- SpeedUnit; the unit of the xyz parameters- Throws:
ValueRuntimeException
- in case the units are incorrect
-
Speed3D
Construct a new Speed3D from a strongly typed speed and polar coordinates.- Parameters:
speed
- Speed; the speed in the direction of the angle along the vectortheta
- Direction; the angle from the z directionphi
- Direction; the projected angle in the xy-plane from the x direction- Throws:
ValueRuntimeException
- in case the vector does not have exactly three elements
-
-
Method Details
-
getX
Retrieve the x-component of this Speed3D.- Returns:
- the speed in the x-direction.
-
getY
Retrieve the y-component of this Speed3D.- Returns:
- the speed in the y-direction.
-
getZ
Retrieve the z-component of this Speed3D.- Returns:
- the speed in the z-direction.
-
getTheta
Retrieve the theta of this Speed3D.- Returns:
- the angle of direction perpendicular to the xy-plane
-
getPhi
Retrieve the phi of this Speed3D.- Returns:
- the projected angle of direction in the xy-plane
-
getSpeed
Retrieve the norm of this Speed3D.- Returns:
- the combined speed in the direction of the angle
-
toString
public final java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-