public double AngleTo(Vector2d to) { return(Mathd.Atan2(Cross(to), Dot(to))); }
public bool IsNormalized() { return(Mathd.Abs(LengthSquared() - 1.0f) < Mathd.Epsilon); }
/// <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()); }
/// <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)); }
public double DistanceTo(Vector2d to) { return(Mathd.Sqrt((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y))); }
/// <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))); }
/// <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))); }
/// <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); }
/// <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)); }
public Vector4d Round() { return(new Vector4d(Mathd.Round(x), Mathd.Round(y), Mathd.Round(z), Mathd.Round(w))); }
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)); }
public Vector4d Floor() { return(new Vector4d(Mathd.Floor(x), Mathd.Floor(y), Mathd.Floor(z), Mathd.Floor(w))); }
public Vector4d Ceil() { return(new Vector4d(Mathd.Ceil(x), Mathd.Ceil(y), Mathd.Ceil(z), Mathd.Ceil(w))); }
public Vector4d Abs() { return(new Vector4d(Mathd.Abs(x), Mathd.Abs(y), Mathd.Abs(z), Mathd.Abs(w))); }
public double AngleToPoint(Vector2d to) { return(Mathd.Atan2(y - to.y, x - to.x)); }
public Vector2d Rotated(double phi) { double rads = Angle() + phi; return(new Vector2d(Mathd.Cos(rads), Mathd.Sin(rads)) * Length()); }
/// <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))); }
public Vector2d Round() { return(new Vector2d(Mathd.Round(x), Mathd.Round(y))); }
/// <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))); }
public Vector2d Snapped(Vector2d by) { return(new Vector2d(Mathd.Stepify(x, by.x), Mathd.Stepify(y, by.y))); }
/// <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))); }
public bool Equals(Vector2d other) { return(Mathd.IsEqualApprox(x, other.x) && Mathd.IsEqualApprox(y, other.y)); }
public Vector2d Ceil() { return(new Vector2d(Mathd.Ceil(x), Mathd.Ceil(y))); }
public Vector2d Abs() { return(new Vector2d(Mathd.Abs(x), Mathd.Abs(y))); }
public Vector2d Floor() { return(new Vector2d(Mathd.Floor(x), Mathd.Floor(y))); }
public double Angle() { return(Mathd.Atan2(y, x)); }
public double Length() { return(Mathd.Sqrt(x * x + y * y)); }
public bool Equals(Planed other) { return(_normal == other._normal && Mathd.IsEqualApprox(D, other.D)); }