Class Scalar3d

java.lang.Object
org.opentrafficsim.core.math.Scalar3d

public final class Scalar3d extends Object
Calculate between Polar (spherical) and Cartesian (xyz) coordinates.

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
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.djunits.value.vdouble.scalar.Direction
    cartesianToPhi(double x, double y)
    Get the (polar) phi angle, which is the projected angle in the xy-plane from the x direction.
    static double
    cartesianToRadius(double x, double y, double z)
    Get the (polar) radius based on Cartesian coordinates.
    static org.djunits.value.vdouble.scalar.Direction
    cartesianToTheta(double x, double y, double z)
    Get the (polar) theta angle, which is the angle from the z-direction, from Cartesian coordinates.
    static double[]
    polarToCartesian(double r, double theta, double phi)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • polarToCartesian

      public static double[] polarToCartesian(double r, double theta, double phi)
      Parameters:
      r - double; the radius
      theta - double; the angle from the z direction
      phi - double; the projected angle in the xy-plane from the x direction
      Returns:
      a double array [x, y, z] with cartesian coordinates
    • cartesianToRadius

      public static double cartesianToRadius(double x, double y, double z)
      Get the (polar) radius based on Cartesian coordinates.
      Parameters:
      x - double; the x-coordinate
      y - double; the y-coordinate
      z - double; the z-coordinate
      Returns:
      the radius, which is the distance from (0,0,0)
    • cartesianToTheta

      public static org.djunits.value.vdouble.scalar.Direction cartesianToTheta(double x, double y, double z)
      Get the (polar) theta angle, which is the angle from the z-direction, from Cartesian coordinates.
      Parameters:
      x - double; the x-coordinate
      y - double; the y-coordinate
      z - double; the z-coordinate
      Returns:
      the radius, which is the distance from (0,0,0)
    • cartesianToPhi

      public static org.djunits.value.vdouble.scalar.Direction cartesianToPhi(double x, double y)
      Get the (polar) phi angle, which is the projected angle in the xy-plane from the x direction.
      Parameters:
      x - double; the x-coordinate
      y - double; the y-coordinate
      Returns:
      the projected angle of direction in the xy-plane