Пример #1
0
 public double AngleTo(Vector2d to)
 {
     return(Mathd.Atan2(Cross(to), Dot(to)));
 }
Пример #2
0
 public bool IsNormalized()
 {
     return(Mathd.Abs(LengthSquared() - 1.0f) < Mathd.Epsilon);
 }
Пример #3
0
 /// <summary>
 /// Returns an AABBd with equivalent position and size, modified so that
 /// the most-negative corner is the origin and the size is positive.
 /// </summary>
 /// <returns>The modified AABBd.</returns>
 public AABBd Abs()
 {
     Vector3d end = End;
     Vector3d topLeft = new Vector3d(Mathd.Min(_position.x, end.x), Mathd.Min(_position.y, end.y), Mathd.Min(_position.z, end.z));
     return new AABBd(topLeft, _size.Abs());
 }
Пример #4
0
 /// <summary>
 /// Returns true if this vector and `other` are approximately equal, by running
 /// <see cref="Mathd.IsEqualApprox(double, double)"/> on each component.
 /// </summary>
 /// <param name="other">The other vector to compare.</param>
 /// <returns>Whether or not the vectors are approximately equal.</returns>
 public bool IsEqualApprox(Vector3d other)
 {
     return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y) && Mathd.IsEqualApprox(z, other.z));
 }
Пример #5
0
 public double DistanceTo(Vector2d to)
 {
     return(Mathd.Sqrt((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y)));
 }
Пример #6
0
 /// <summary>
 /// Returns the unsigned minimum angle to the given vector, in radians.
 /// </summary>
 /// <param name="to">The other vector to compare this vector to.</param>
 /// <returns>The unsigned angle between the two vectors, in radians.</returns>
 public double AngleTo(Vector3d to)
 {
     return(Mathd.Atan2(Cross(to).Length(), Dot(to)));
 }
Пример #7
0
 /// <summary>
 /// Returns a new vector with all components rounded down (towards negative infinity).
 /// </summary>
 /// <returns>A vector with <see cref="Mathd.Floor"/> called on each component.</returns>
 public Vector3d Floor()
 {
     return(new Vector3d(Mathd.Floor(x), Mathd.Floor(y), Mathd.Floor(z)));
 }
Пример #8
0
        /// <summary>
        /// Returns true if point is inside the plane.
        /// Comparison uses a custom minimum epsilon threshold.
        /// </summary>
        /// <param name="point">The point to check.</param>
        /// <param name="epsilon">The tolerance threshold.</param>
        /// <returns>A bool for whether or not the plane has the point.</returns>
        public bool HasPoint(Vector3d point, double epsilon = Mathd.Epsilon)
        {
            double dist = _normal.Dot(point) - D;

            return(Mathd.Abs(dist) <= epsilon);
        }
Пример #9
0
 /// <summary>
 /// Returns true if this plane and `other` are approximately equal, by running
 /// <see cref="Mathd.IsEqualApprox(double, double)"/> on each component.
 /// </summary>
 /// <param name="other">The other plane to compare.</param>
 /// <returns>Whether or not the planes are approximately equal.</returns>
 public bool IsEqualApprox(Planed other)
 {
     return(_normal.IsEqualApprox(other._normal) && Mathd.IsEqualApprox(D, other.D));
 }
Пример #10
0
 public Vector4d Round()
 {
     return(new Vector4d(Mathd.Round(x), Mathd.Round(y), Mathd.Round(z), Mathd.Round(w)));
 }
Пример #11
0
 public bool Equals(Vector4d other)
 {
     return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y) && Mathd.IsEqualApprox(z, other.z) && Mathd.IsEqualApprox(w, other.w));
 }
Пример #12
0
 public Vector4d Floor()
 {
     return(new Vector4d(Mathd.Floor(x), Mathd.Floor(y), Mathd.Floor(z), Mathd.Floor(w)));
 }
Пример #13
0
 public Vector4d Ceil()
 {
     return(new Vector4d(Mathd.Ceil(x), Mathd.Ceil(y), Mathd.Ceil(z), Mathd.Ceil(w)));
 }
Пример #14
0
 public Vector4d Abs()
 {
     return(new Vector4d(Mathd.Abs(x), Mathd.Abs(y), Mathd.Abs(z), Mathd.Abs(w)));
 }
Пример #15
0
 public double AngleToPoint(Vector2d to)
 {
     return(Mathd.Atan2(y - to.y, x - to.x));
 }
Пример #16
0
        public Vector2d Rotated(double phi)
        {
            double rads = Angle() + phi;

            return(new Vector2d(Mathd.Cos(rads), Mathd.Sin(rads)) * Length());
        }
Пример #17
0
 /// <summary>
 /// Returns a new vector with all components in absolute values (i.e. positive).
 /// </summary>
 /// <returns>A vector with <see cref="Mathd.Abs(double)"/> called on each component.</returns>
 public Vector3d Abs()
 {
     return(new Vector3d(Mathd.Abs(x), Mathd.Abs(y), Mathd.Abs(z)));
 }
Пример #18
0
 public Vector2d Round()
 {
     return(new Vector2d(Mathd.Round(x), Mathd.Round(y)));
 }
Пример #19
0
 /// <summary>
 /// Returns a new vector with all components rounded up (towards positive infinity).
 /// </summary>
 /// <returns>A vector with <see cref="Mathd.Ceil"/> called on each component.</returns>
 public Vector3d Ceil()
 {
     return(new Vector3d(Mathd.Ceil(x), Mathd.Ceil(y), Mathd.Ceil(z)));
 }
Пример #20
0
 public Vector2d Snapped(Vector2d by)
 {
     return(new Vector2d(Mathd.Stepify(x, by.x), Mathd.Stepify(y, by.y)));
 }
Пример #21
0
 /// <summary>
 /// Returns this vector with all components rounded to the nearest integer,
 /// with halfway cases rounded towards the nearest multiple of two.
 /// </summary>
 /// <returns>The rounded vector.</returns>
 public Vector3d Round()
 {
     return(new Vector3d(Mathd.Round(x), Mathd.Round(y), Mathd.Round(z)));
 }
Пример #22
0
 public bool Equals(Vector2d other)
 {
     return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y));
 }
Пример #23
0
 public Vector2d Ceil()
 {
     return(new Vector2d(Mathd.Ceil(x), Mathd.Ceil(y)));
 }
Пример #24
0
 public Vector2d Abs()
 {
     return(new Vector2d(Mathd.Abs(x), Mathd.Abs(y)));
 }
Пример #25
0
 public Vector2d Floor()
 {
     return(new Vector2d(Mathd.Floor(x), Mathd.Floor(y)));
 }
Пример #26
0
 public double Angle()
 {
     return(Mathd.Atan2(y, x));
 }
Пример #27
0
 public double Length()
 {
     return(Mathd.Sqrt(x * x + y * y));
 }
Пример #28
0
 public bool Equals(Planed other)
 {
     return(_normal == other._normal && Mathd.IsEqualApprox(D, other.D));
 }