Package org.opentrafficsim.core.math
Class Speed3d
java.lang.Object
org.opentrafficsim.core.math.Speed3d
- All Implemented Interfaces:
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-2024 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:
-
Constructor Summary
ConstructorDescriptionSpeed3d
(double x, double y, double z, org.djunits.unit.SpeedUnit unit) Construct a new Speed3d from three double Cartesian coordinates and a speed unit.Speed3d
(org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Direction theta, org.djunits.value.vdouble.scalar.Direction phi) Construct a new Speed3d from a strongly typed speed and polar coordinates.Speed3d
(org.djunits.value.vdouble.scalar.Speed x, org.djunits.value.vdouble.scalar.Speed y, org.djunits.value.vdouble.scalar.Speed z) Construct a new Speed3d from three strongly typed Cartesian coordinates.Speed3d
(org.djunits.value.vdouble.vector.SpeedVector speed) Construct a new Speed3d from vector of strongly typed Cartesian coordinates. -
Method Summary
Modifier and TypeMethodDescriptionfinal org.djunits.value.vdouble.scalar.Direction
getPhi()
Retrieve the phi of this Speed3d.final org.djunits.value.vdouble.scalar.Speed
getSpeed()
Retrieve the norm of this Speed3d.final org.djunits.value.vdouble.scalar.Direction
getTheta()
Retrieve the theta of this Speed3d.final org.djunits.value.vdouble.scalar.Speed
getX()
Retrieve the x-component of this Speed3d.final org.djunits.value.vdouble.scalar.Speed
getY()
Retrieve the y-component of this Speed3d.final org.djunits.value.vdouble.scalar.Speed
getZ()
Retrieve the z-component of this Speed3d.final String
toString()
-
Constructor Details
-
Speed3d
public Speed3d(org.djunits.value.vdouble.vector.SpeedVector speed) throws org.djunits.value.ValueRuntimeException Construct a new Speed3d from vector of strongly typed Cartesian coordinates.- Parameters:
speed
- SpeedVector; the speeds in 3D (YPR coded)- Throws:
org.djunits.value.ValueRuntimeException
- in case the vector does not have exactly three elements
-
Speed3d
public Speed3d(org.djunits.value.vdouble.scalar.Speed x, org.djunits.value.vdouble.scalar.Speed y, org.djunits.value.vdouble.scalar.Speed z) throws org.djunits.value.ValueRuntimeException 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:
org.djunits.value.ValueRuntimeException
- in case the units are incorrect
-
Speed3d
public Speed3d(double x, double y, double z, org.djunits.unit.SpeedUnit unit) throws org.djunits.value.ValueRuntimeException 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:
org.djunits.value.ValueRuntimeException
- in case the units are incorrect
-
Speed3d
public Speed3d(org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Direction theta, org.djunits.value.vdouble.scalar.Direction phi) throws org.djunits.value.ValueRuntimeException 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:
org.djunits.value.ValueRuntimeException
- in case the vector does not have exactly three elements
-
-
Method Details
-
getX
public final org.djunits.value.vdouble.scalar.Speed getX()Retrieve the x-component of this Speed3d.- Returns:
- the speed in the x-direction.
-
getY
public final org.djunits.value.vdouble.scalar.Speed getY()Retrieve the y-component of this Speed3d.- Returns:
- the speed in the y-direction.
-
getZ
public final org.djunits.value.vdouble.scalar.Speed getZ()Retrieve the z-component of this Speed3d.- Returns:
- the speed in the z-direction.
-
getTheta
public final org.djunits.value.vdouble.scalar.Direction getTheta()Retrieve the theta of this Speed3d.- Returns:
- the angle of direction perpendicular to the xy-plane
-
getPhi
public final org.djunits.value.vdouble.scalar.Direction getPhi()Retrieve the phi of this Speed3d.- Returns:
- the projected angle of direction in the xy-plane
-
getSpeed
public final org.djunits.value.vdouble.scalar.Speed getSpeed()Retrieve the norm of this Speed3d.- Returns:
- the combined speed in the direction of the angle
-
toString
-