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:- theta is the angle from the z direction.
- phi is the projected angle in the xy-plane from the x direction.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Dec 10, 2015
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
All Methods Instance Methods Concrete Methods 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 Detail
-
Speed3D
public Speed3D(SpeedVector speed) throws ValueRuntimeException
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
public Speed3D(Speed x, Speed y, Speed z) throws 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:
ValueRuntimeException
- in case the units are incorrect
-
Speed3D
public Speed3D(double x, double y, double z, SpeedUnit unit) throws 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:
ValueRuntimeException
- in case the units are incorrect
-
Speed3D
public Speed3D(Speed speed, Direction theta, Direction phi) throws 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:
ValueRuntimeException
- in case the vector does not have exactly three elements
-
-
Method Detail
-
getX
public final Speed getX()
Retrieve the x-component of this Speed3D.- Returns:
- the speed in the x-direction.
-
getY
public final Speed getY()
Retrieve the y-component of this Speed3D.- Returns:
- the speed in the y-direction.
-
getZ
public final Speed getZ()
Retrieve the z-component of this Speed3D.- Returns:
- the speed in the z-direction.
-
getTheta
public final Direction getTheta()
Retrieve the theta of this Speed3D.- Returns:
- the angle of direction perpendicular to the xy-plane
-
getPhi
public final Direction getPhi()
Retrieve the phi of this Speed3D.- Returns:
- the projected angle of direction in the xy-plane
-
getSpeed
public final Speed 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
-
-