/// <summary> /// Writes Vector3 with -1, 1 range (uniform-spacing) with specified bit precision. /// </summary> public static void WriteNormalizedSignedVector3(this BitStream stream, Vector3 vec, int bitCount) { vec = Vector3.Clamp(vec, Vector3.MinusOne, Vector3.One); stream.WriteNormalizedSignedFloat(vec.X, bitCount); stream.WriteNormalizedSignedFloat(vec.Y, bitCount); stream.WriteNormalizedSignedFloat(vec.Z, bitCount); }
/// <summary>Get the nearest point between this <see cref="Box3"/> and a <see cref="Vector3"/>. If the <see cref="Vector3"/> is inside this <see cref="Box3"/>, it is returned untouched.</summary> public Vector3 NearestPointTo( Vector3 point ) { Vector3 result; Containment containment = Intersect(ref point); if(containment != Containment.Disjoint) result = point; else point.Clamp(ref Min, ref Max, out result); return result; }
/// <summary>Get the nearest point between this <see cref="Box3"/> and a <see cref="Vector3"/>. If the <see cref="Vector3"/> is inside this <see cref="Box3"/>, it is returned untouched.</summary> public void NearestPointTo( ref Vector3 point , out Vector3 result) { Containment containment = Intersect(ref point); if(containment != Containment.Disjoint) result = point; else point.Clamp(ref Min, ref Max, out result); return; }
public static Vector3 Clamp(Vector3 v1, float min, float max) { v1.Clamp(min, max); return(v1); }
public static Vector3 Clamp01(Vector3 value) => Vector3.Clamp(value, Vector3.Zero, Vector3.One);
public static Vector3 Clamp(Vector3 value, Vector3 min, Vector3 max) => Vector3.Clamp(value, min, max);
/// <summary> /// Finds the closest point on a bounding box from another point /// </summary> /// <param name="box"></param> /// <param name="point"></param> /// <returns></returns> public static Vector3 ClosestPoint(this BoundingBox box, Vector3 point) { return point.Clamp(box.Min, box.Max); }
public static Vector3 Clamp(Vector3 v1, float min, float max) { v1.Clamp(min, max); return v1; }