public void LengthResult() { var v3 = new Vect3f(2.0f, 3.0f, 5.0f); Assert.AreEqual(38, v3.LengthSquared, Constants.Delta); Assert.AreEqual(6.1644139289856, v3.Length, Constants.Delta); }
private void GetReferences(string data, out Vect4f v, out Vect3f t, out Vect3f n) { v = null; t = null; n = null; var split = data.Split('/'); switch (split.Length) { case 3: n = Normals[int.Parse(split[2]) - 1]; goto case 2; case 2: t = TextureVertices[int.Parse(split[1]) - 1]; goto case 1; case 1: v = Vertices[int.Parse(split[0]) - 1]; break; default: throw new Exception(); } }
private void SetupBoundingBox() { if (mSteps.Count == mLastOperationCount) { return; } mLimits = new BoundingBox(new Vect3f(0, 0, 0), new Vect3f(0, 0, 0)); foreach (ViewerStep op in mSteps) { CheckOpBoundingBox(op); } mLastOperationCount = mSteps.Count; // Center model Vect3f midPoint = new Vect3f( (mLimits.MinPoint.X - mLimits.MaxPoint.X) / 2, (mLimits.MinPoint.Y - mLimits.MaxPoint.Y) / 2, 0f); mViewControl.Translation = midPoint; }
private void CheckPointBoundingBox(Vect3f p) { if (p.X > mLimits.MaxPoint.X) { mLimits.MaxPoint.X = p.X; } if (p.Y > mLimits.MaxPoint.Y) { mLimits.MaxPoint.Y = p.Y; } if (p.Z > mLimits.MaxPoint.Z) { mLimits.MaxPoint.Z = p.Z; } if (p.X < mLimits.MinPoint.X) { mLimits.MinPoint.X = p.X; } if (p.Y < mLimits.MinPoint.Y) { mLimits.MinPoint.Y = p.Y; } if (p.Z < mLimits.MinPoint.Z) { mLimits.MinPoint.Z = p.Z; } }
public static dynamic Swizzle(this Vect3f v) { var s = new Swizzle <float>(); s.Add('X', v.X); s.Add('Y', v.Y); s.Add('Z', v.Z); return(s); }
public void CreationFromList() { var x = 2.0f; var y = 3.0f; var z = 5.0f; var v3 = new Vect3f(new[] { x, y, z }); Assert.AreEqual(x, v3.X, Constants.Delta); Assert.AreEqual(y, v3.Y, Constants.Delta); Assert.AreEqual(z, v3.Z, Constants.Delta); }
public static Mat4f LookAt(Vect3f eye, Vect3f target, Vect3f up) { var vector31 = (eye - target).Normalize(); var right = up.CrossProduct(vector31).Normalize(); var vector32 = vector31.CrossProduct(right).Normalize(); return(new Mat4f(new[, ] { { right.X, right.Y, right.Z, 0 }, { vector32.X, vector32.Y, vector32.Z, 0 }, { vector31.X, vector31.Y, vector31.Z, 0 }, { 0, 0, 0, 1 } }) * Translate(-eye)); }
public void CreationFromListTooLong() { try { var v = new Vect3f(new[] { 2.0f, 3.0f, 5.0f, 7.0f }); Assert.Fail(); // If it gets to this line, no exception was thrown } catch (ArgumentException) { } catch (Exception) { Assert.Fail(); } }
public void Equality() { var a = new Vect3f(2.0f, 3.0f, 5.0f); var b = new Vect3f(2.0f, 3.0f, 5.0f); var c = new Vect3f(3.0f, 3.0f, 6.0f); var d = a; Assert.IsTrue(a.Equals(b)); Assert.IsFalse(a.Equals(c)); Assert.IsTrue(a.Equals(d)); Assert.AreEqual(a, b); Assert.AreNotEqual(a, c); Assert.AreEqual(a, d); Assert.IsTrue(a == b); Assert.IsTrue(a != c); Assert.IsTrue(a != null); }
public ViewerStep(float fromX, float fromY, float fromZ, float toX, float toY, float toZ) { Start = new Vect3f(fromX, fromY, fromZ); if (toX == float.MinValue) { toX = fromX; } if (toY == float.MinValue) { toY = fromY; } if (toZ == float.MinValue) { toZ = fromZ; } End = new Vect3f(toX, toY, toZ); Distance = (float)Math.Sqrt( Math.Pow(toX - fromX, 2) + Math.Pow(toY - fromY, 2) + Math.Pow(toZ - fromZ, 2)); }
public static Mat4f Translate(Vect3f v) { return(Translate(v.X, v.Y, v.Z)); }