public vector Clip(vector min, vector max) { vector v = this; if (v.X < min.X) { v.X = min.X; } else if (max.X < v.X) { v.X = max.X; } if (v.Y < min.Y) { v.Y = min.Y; } else if (max.Y < v.Y) { v.Y = max.Y; } if (v.Z < min.Z) { v.Z = min.Z; } else if (max.Z < v.Z) { v.Z = max.Z; } return(v); }
public void ClipSelf(vector min, vector max) { if (X < min.X) { X = min.X; } else if (max.X < X) { X = max.X; } if (Y < min.Y) { Y = min.Y; } else if (max.Y < Y) { Y = max.Y; } if (Z < min.Z) { Z = min.Z; } else if (max.Z < Z) { Z = max.Z; } }
public bool LessIdThan(vector v) { if (X < v.X) { return(true); } if (X > v.X) { return(false); } if (Y < v.Y) { return(true); } if (Y > v.Y) { return(false); } if (Z < v.Z) { return(true); } if (Z > v.Z) { return(false); } return(false); }
public Obb3i(vector center, vector extents, vector ax, vector ay, vector az) { Center = center; Extents = extents; Ax = ax; Ay = ay; Az = az; }
public Obb3i(aabb aabb) { Center = aabb.Center; Extents = aabb.Extents; Ax = vector.AxisX; Ay = vector.AxisY; Az = vector.AxisZ; }
public Obb3i(Obb3d v) { Center = new vector(v.Center); Extents = new vector(v.Extents); Ax = new vector(v.Ax); Ay = new vector(v.Ay); Az = new vector(v.Az); }
public Range3i(IEnumerable <vector> positions) { vector min = vector.MaxValue, max = vector.MinValue; foreach (var p in positions) { min.ElementWiseMinSelf(p); max.ElementWiseMaxSelf(p); } Min = min; Max = max; }
public Range3i(IEnumerable <volume> volumes) { vector min = vector.MaxValue, max = vector.MinValue; foreach (var v in volumes) { min.ElementWiseMinSelf(v.Min); max.ElementWiseMaxSelf(v.Max); } Min = min; Max = max; }
public Range3i(vector min, vector max, bool normalize) { if (normalize) { vector.ElementWiseMinMax(min, max, out Min, out Max); } else { Min = min; Max = max; } }
public void ElementWiseMinSelf(vector v) { if (v.X < X) { X = v.X; } if (v.Y < Y) { Y = v.Y; } if (v.Z < Z) { Z = v.Z; } }
public void ElementWiseMaxSelf(vector v) { if (v.X > X) { X = v.X; } if (v.Y > Y) { Y = v.Y; } if (v.Z > Z) { Z = v.Z; } }
static public vector ElementWiseMax(vector v1, vector v2) { if (v2.X < v1.X) { v2.X = v1.X; } if (v2.Y < v1.Y) { v2.Y = v1.Y; } if (v2.Z < v1.Z) { v2.Z = v1.Z; } return(v2); }
public static void ElementWiseMinMax(vector v1, vector v2, out vector min, out vector max) { if (v2.X < v1.X) { var t = v1.X; v1.X = v2.X; v2.X = t; } ; if (v2.Y < v1.Y) { var t = v1.Y; v1.Y = v2.Y; v2.Y = t; } ; if (v2.Z < v1.Z) { var t = v1.Z; v1.Z = v2.Z; v2.Z = t; } ; min = v1; max = v2; }
public Range3i(vector min, vector max) { Min = min; Max = max; }
public Range3i(vector position) { Min = position; Max = position; }
public void ExpandSelf(vector v) { Min.SubSelf(v); Max.AddSelf(v); }
public volume Expand(vector v) { return(new volume(Min - v, Max + v)); }
public void MergeSelf(vector v) { Min.ElementWiseMinSelf(v); Max.ElementWiseMaxSelf(v); }
public element Dot(vector v) { return(X * v.X + Y * v.Y + Z * v.Z); }
public Aabb3i(vector center, vector extents) { Center = center; Extents = extents; }
public void MulSelf(vector v) { X *= v.X; Y *= v.Y; Z *= v.Z; }
public vector Cross(vector v) { return(new vector(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X)); }
public void SubSelf(vector v) { X -= v.X; Y -= v.Y; Z -= v.Z; }
public bool Contains(vector v) { v.SubSelf(Center); v = (Ax * v.X) + (Ay * v.Y) + (Az * v.Z); return(Math.Abs(v.X) <= Extents.X && Math.Abs(v.Y) <= Extents.Y && Math.Abs(v.Z) <= Extents.Z); }
public Range3i(Range3d v) { Min = new vector(v.Min); Max = new vector(v.Max); }
public volume Merge(vector v) { return(new volume(vector.ElementWiseMin(Min, v), vector.ElementWiseMax(Max, v))); }
public Aabb3i(Aabb3d v) { Center = new vector(v.Center); Extents = new vector(v.Extents); }
public void DivSelf(vector v) { X /= v.X; Y /= v.Y; Z /= v.Z; }
public bool Contains(vector v) { return(Min <= v && v <= Max); }
public void AddSelf(vector v) { X += v.X; Y += v.Y; Z += v.Z; }