Class Direction3d

java.lang.Object
org.djutils.draw.Direction3d

public class Direction3d extends Object
Class encoding a direction in 3d space. It combines dirY (similar to tilt; measured as an angle from the positive z-direction) and dirZ (similar to pan; measured as an angle from the positive x-direction).

Copyright (c) 2023-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double
    Rotation around y-axis.
    final double
    Rotation around z-axis.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Direction3d(double dirY, double dirZ)
    Construct a Direction3d.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Determine the angle between this Direction3d and another Direction3d.
    boolean
     
    double
    Retrieve the dirY component of this Direction3d.
    double
    Retrieve the dirZ component of this Direction3d.
    int
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • dirY

      public final double dirY
      Rotation around y-axis.
    • dirZ

      public final double dirZ
      Rotation around z-axis.
  • Constructor Details

    • Direction3d

      public Direction3d(double dirY, double dirZ)
      Construct a Direction3d.
      Parameters:
      dirY - the dirY component for the new Direction3d
      dirZ - the dirZ component for the new Direction3d
      Throws:
      ArithmeticException - when dirY, or dirZ is NaN
      IllegalArgumentException - when dirY, or dirZ is infinite
  • Method Details

    • getDirY

      public double getDirY()
      Retrieve the dirY component of this Direction3d.
      Returns:
      the dirY component of this Direction3d
    • getDirZ

      public double getDirZ()
      Retrieve the dirZ component of this Direction3d.
      Returns:
      the dirZ component of this Direction3d
    • directionDifference

      public double directionDifference(Direction3d otherDirection)
      Determine the angle between this Direction3d and another Direction3d. Liberally based on https://www.cuemath.com/geometry/angle-between-vectors/
      Parameters:
      otherDirection - the other Direction3d
      Returns:
      double the angle in Radians
      Throws:
      NullPointerException - when otherDirection is null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object