using System; using UnityEngine; namespace Framework.Geometry.Lines { /// 3D infinite line public struct Line3 { /// A default line public static readonly Line3 Default = new Line3(Vector3.zero, Vector3.right); /// Offset of the line from the coordinate system's center public Vector3 Offset; /// Direction along which the line runs public Vector3 Direction; /// Initializes a new line /// /// X coordinate of the line's offset from the coordinate system's center /// /// /// Y coordinate of the line's offset from the coordinate system's center /// /// /// Z coordinate of the line's offset from the coordinate system's center /// /// /// X coordinate of the direction along which the line runs /// /// /// Y coordinate of the direction along which the line runs /// /// /// Z coordinate of the direction along which the line runs /// public Line3( float offsetX, float offsetY, float offsetZ, float directionX, float directionY, float directionZ ) { this.Offset = new Vector3(offsetX, offsetY, offsetZ); this.Direction = new Vector3(directionX, directionY, directionZ); } /// Initializes a new line /// Offset of the line from the coordinate system's center /// Direction along which the line runs public Line3(Vector3 offset, Vector3 direction) { this.Offset = offset; this.Direction = direction; } /// /// Determines whether this instance is identical to another instance /// /// Other instance of compare against /// True if both instances are identical public override bool Equals(object otherObject) { if(!(otherObject is Line3)) { return false; } Line3 other = (Line3)otherObject; return ( (this.Offset == other.Offset) && (this.Direction == other.Direction) ); } /// Returns a hash code for the instance /// The instance's hash code public override int GetHashCode() { return this.Offset.GetHashCode() ^ this.Direction.GetHashCode(); } } } // namespace Framework.Geometry.Lines