Exemple #1
0
        /// <inheritdoc />
        public override dvec3 GetPositionAt(dvec2 uv)
        {
            dvec3  translation = Center;
            double radius      = this.Radius.GetValueAt(uv);

            return(translation + radius * GetNormalAt(uv));
        }
Exemple #2
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat2(dvec2 c0, dvec2 c1)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m10 = c1.x;
     this.m11 = c1.y;
 }
Exemple #3
0
 public void Constructors()
 {
     {
         var v = new dvec2(5d);
         Assert.AreEqual(5d, v.x);
         Assert.AreEqual(5d, v.y);
     }
     {
         var v = new dvec2(-7.5d, 3.5d);
         Assert.AreEqual(-7.5d, v.x);
         Assert.AreEqual(3.5d, v.y);
     }
     {
         var v = new dvec2(new dvec2(-5d, 4.5d));
         Assert.AreEqual(-5d, v.x);
         Assert.AreEqual(4.5d, v.y);
     }
     {
         var v = new dvec2(new dvec3(-3d, 4.5d, -8.5d));
         Assert.AreEqual(-3d, v.x);
         Assert.AreEqual(4.5d, v.y);
     }
     {
         var v = new dvec2(new dvec4(2.5d, 1.5d, -3.5d, -8d));
         Assert.AreEqual(2.5d, v.x);
         Assert.AreEqual(1.5d, v.y);
     }
 }
Exemple #4
0
 /// <summary>
 ///		Constructs a ShiftedMap2D whose input is shifted by a dvec2 and stretched by another dvec2.
 /// </summary>
 /// <param name="shift">
 ///     The vector by which the 2D map is shifted.
 /// </param>
 /// <param name="stretch">
 ///     The vector by which the 2D map's coordinates are multiplied.
 /// </param>
 /// <param name="function">
 ///     The ContinuousMap that is shifted and stretched.
 /// </param>
 public ShiftedMap2D(dvec2 shift, dvec2 stretch, ContinuousMap <dvec2, TOut> function)
 {
     DebugUtil.AssertAllFinite(shift, nameof(shift));
     DebugUtil.AssertAllFinite(stretch, nameof(stretch));
     this.Shift    = shift;
     this.Stretch  = stretch;
     this.Function = function;
 }
Exemple #5
0
 public static void Transform(this CSGeom.D2.Loop loop, dmat4 transform)
 {
     for (int i = 0; i < loop.Count; i++)
     {
         dvec2 tmp = new dvec2(transform * new dvec4(loop[i].x, loop[i].y, 0, 1));
         loop[i] = new CSGeom.gvec2(tmp.x, tmp.y);
     }
 }
Exemple #6
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat3x2(dvec2 c0, dvec2 c1)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m20 = 0.0;
     this.m21 = 0.0;
 }
Exemple #7
0
        public void PropertyValues()
        {
            var v    = new dvec2(-9d, 9.5d);
            var vals = v.Values;

            Assert.AreEqual(-9d, vals[0]);
            Assert.AreEqual(9.5d, vals[1]);
            Assert.That(vals.SequenceEqual(v.ToArray()));
        }
Exemple #8
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat3x2(dvec2 c0, dvec2 c1, dvec2 c2)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m20 = c2.x;
     this.m21 = c2.y;
 }
Exemple #9
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat2x3(dvec2 c0, dvec2 c1)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m02 = 0.0;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m12 = 0.0;
 }
Exemple #10
0
        /// <inheritdoc />
        public override dvec3 GetPositionAt(dvec2 uv)
        {
            DebugUtil.AssertAllFinite(uv, nameof(uv));
            double v = uv.y;

            dvec3  translation = CenterCurve.GetPositionAt(v);
            double radius      = Radius.GetValueAt(uv);

            return(translation + radius * GetNormalAt(uv));
        }
Exemple #11
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat4x2(dvec2 c0, dvec2 c1, dvec2 c2, dvec2 c3)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m20 = c2.x;
     this.m21 = c2.y;
     this.m30 = c3.x;
     this.m31 = c3.y;
 }
Exemple #12
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat4x2(dvec2 c0, dvec2 c1, dvec2 c2)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m20 = c2.x;
     this.m21 = c2.y;
     this.m30 = 0.0;
     this.m31 = 0.0;
 }
Exemple #13
0
        public void SerializationJson()
        {
            var v0 = new dvec2(-9.5d, 3.5d);
            var s0 = JsonConvert.SerializeObject(v0);

            var v1 = JsonConvert.DeserializeObject <dvec2>(s0);
            var s1 = JsonConvert.SerializeObject(v1);

            Assert.AreEqual(v0, v1);
            Assert.AreEqual(s0, s1);
        }
Exemple #14
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat3(dvec2 c0, dvec2 c1, dvec2 c2)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m02 = 0.0;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m12 = 0.0;
     this.m20 = c2.x;
     this.m21 = c2.y;
     this.m22 = 1.0;
 }
Exemple #15
0
 public void TriangleInequality()
 {
     {
         var v0 = new dvec2(0.5d, -8.5d);
         var v1 = new dvec2(6d, 3d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(8d, -7.5d);
         var v1 = new dvec2(9d, 7d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(6d, 0.5d);
         var v1 = new dvec2(-7.5d, 7d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(-8.5d, 2.5d);
         var v1 = new dvec2(9d, 1.0);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(-3d, 2d);
         var v1 = new dvec2(7d, 6d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(5d, 6.5d);
         var v1 = new dvec2(-1.5d, -8d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(2.5d, 7d);
         var v1 = new dvec2(2d, 7.5d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(8.5d, -6d);
         var v1 = new dvec2(7d, 3d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(0.5d, 8d);
         var v1 = new dvec2(4d, -5.5d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
     {
         var v0 = new dvec2(0.5d, -3d);
         var v1 = new dvec2(8d, -8d);
         Assert.GreaterOrEqual(v0.NormMax + v1.NormMax, (v0 + v1).NormMax);
     }
 }
Exemple #16
0
 public void InvariantCommutativeNeg()
 {
     {
         var v0 = new dvec2(1.5d, 3d);
         var v1 = new dvec2(6.5d, -9d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(2d, 9d);
         var v1 = new dvec2(-0.5d, 0.0);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(1.0, 2.5d);
         var v1 = new dvec2(-1d, 9d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(-5.5d, -5d);
         var v1 = new dvec2(0.5d, -1d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(-6.5d, -6.5d);
         var v1 = new dvec2(3d, 1.5d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(-3.5d, 9d);
         var v1 = new dvec2(6d, 3.5d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(1.5d, -5.5d);
         var v1 = new dvec2(-9d, 2d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(-7d, 1.5d);
         var v1 = new dvec2(5d, -1.5d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(-4d, -2d);
         var v1 = new dvec2(-7.5d, 1.0);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
     {
         var v0 = new dvec2(1.5d, 4d);
         var v1 = new dvec2(9.5d, 7d);
         Assert.AreEqual(v0 - v1, -(v1 - v0));
     }
 }
Exemple #17
0
        /// <inheritdoc />
        public override dvec3 GetNormalAt(dvec2 uv)
        {
            double u = uv.x;
            double v = uv.y;

            // Calculate the position of the rings of vertices:
            double x = Math.Sin(v) * Math.Cos(u);
            double y = Math.Sin(v) * Math.Sin(u);
            double z = Math.Cos(v);

            return(x * Normal + y * Binormal + z * Direction);
        }
Exemple #18
0
 public void InvariantCommutative()
 {
     {
         var v0 = new dvec2(4.5d, -4d);
         var v1 = new dvec2(7d, 7d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(3.5d, -7.5d);
         var v1 = new dvec2(-4d, -1.5d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-2d, -7d);
         var v1 = new dvec2(0.0, 4.5d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-4d, -4.5d);
         var v1 = new dvec2(-2d, -7d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-6d, -7.5d);
         var v1 = new dvec2(-1.5d, -0.5d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-5.5d, 2.5d);
         var v1 = new dvec2(-9d, -0.5d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-2.5d, -2d);
         var v1 = new dvec2(-6d, -4d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-7.5d, -5.5d);
         var v1 = new dvec2(1.0, 2.5d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(-1.5d, -9d);
         var v1 = new dvec2(2.5d, 9d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
     {
         var v0 = new dvec2(1.5d, -9d);
         var v1 = new dvec2(2.5d, 6.5d);
         Assert.AreEqual(v0 * v1, v1 * v0);
     }
 }
Exemple #19
0
        public void Operators()
        {
            var v1 = new dvec2(-7.5d, 1.0);
            var v2 = new dvec2(-7.5d, 1.0);
            var v3 = new dvec2(1.0, -7.5d);

            Assert.That(v1 == new dvec2(v1));
            Assert.That(v2 == new dvec2(v2));
            Assert.That(v3 == new dvec2(v3));
            Assert.That(v1 == v2);
            Assert.That(v1 != v3);
            Assert.That(v2 != v3);
        }
Exemple #20
0
        public void StringInterop()
        {
            var v = new dvec2(-6.5d, 4.5d);

            var s0 = v.ToString();
            var s1 = v.ToString("#");

            var v0 = dvec2.Parse(s0);
            var v1 = dvec2.Parse(s1, "#");

            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            var b0 = dvec2.TryParse(s0, out v0);
            var b1 = dvec2.TryParse(s1, "#", out v1);

            Assert.That(b0);
            Assert.That(b1);
            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            b0 = dvec2.TryParse(null, out v0);
            Assert.False(b0);
            b0 = dvec2.TryParse("", out v0);
            Assert.False(b0);
            b0 = dvec2.TryParse(s0 + ", 0", out v0);
            Assert.False(b0);

            Assert.Throws <NullReferenceException>(() => { dvec2.Parse(null); });
            Assert.Throws <FormatException>(() => { dvec2.Parse(""); });
            Assert.Throws <FormatException>(() => { dvec2.Parse(s0 + ", 0"); });

            var s2 = v.ToString(";", CultureInfo.InvariantCulture);

            Assert.That(s2.Length > 0);

            var s3 = v.ToString("; ", "G");
            var s4 = v.ToString("; ", "G", CultureInfo.InvariantCulture);
            var v3 = dvec2.Parse(s3, "; ", NumberStyles.Number);
            var v4 = dvec2.Parse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture);

            Assert.AreEqual(v, v3);
            Assert.AreEqual(v, v4);

            var b4 = dvec2.TryParse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture, out v4);

            Assert.That(b4);
            Assert.AreEqual(v, v4);
        }
Exemple #21
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat3x4(dvec2 c0, dvec2 c1)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m02 = 0.0;
     this.m03 = 0.0;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m12 = 0.0;
     this.m13 = 0.0;
     this.m20 = 0.0;
     this.m21 = 0.0;
     this.m22 = 1.0;
     this.m23 = 0.0;
 }
Exemple #22
0
 /// <summary>
 /// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
 /// </summary>
 public dmat4x3(dvec2 c0, dvec2 c1, dvec2 c2, dvec2 c3)
 {
     this.m00 = c0.x;
     this.m01 = c0.y;
     this.m02 = 0.0;
     this.m10 = c1.x;
     this.m11 = c1.y;
     this.m12 = 0.0;
     this.m20 = c2.x;
     this.m21 = c2.y;
     this.m22 = 1.0;
     this.m30 = c3.x;
     this.m31 = c3.y;
     this.m32 = 0.0;
 }
Exemple #23
0
        /// <inheritdoc />
        public override dvec3 GetNormalAt(dvec2 uv)
        {
            DebugUtil.AssertAllFinite(uv, nameof(uv));
            double u = uv.x;
            double v = uv.y;

            dvec3 curveTangent  = CenterCurve.GetTangentAt(v).Normalized;
            dvec3 curveNormal   = CenterCurve.GetNormalAt(v).Normalized;
            dvec3 curveBinormal = dvec3.Cross(curveTangent, curveNormal);

            double startAngle = StartAngle.GetValueAt(v);
            double endAngle   = EndAngle.GetValueAt(v);

            return(Math.Cos(u) * curveNormal + Math.Sin(u) * curveBinormal);
        }
Exemple #24
0
        public void update()
        {
            float ratio = 1.0f;

            if (Glfw.GetKey(_window, Keys.LeftControl) == InputState.Press)
            {
                ratio = 0.1f;
            }

            if (Glfw.GetKey(_window, Keys.LeftShift) == InputState.Press)
            {
                ratio = 2f;
            }

            if (Glfw.GetKey(_window, Keys.W) == InputState.Press)
            {
                position += orientation * 0.05f * ratio;
            }

            if (Glfw.GetKey(_window, Keys.S) == InputState.Press)
            {
                position -= orientation * 0.05f * ratio;
            }

            if (Glfw.GetKey(_window, Keys.A) == InputState.Press)
            {
                position += _sideOrientation * 0.05f * ratio;
            }

            if (Glfw.GetKey(_window, Keys.D) == InputState.Press)
            {
                position -= _sideOrientation * 0.05f * ratio;
            }

            dvec2 mouseOffset = new dvec2();

            Glfw.GetCursorPosition(_window, out mouseOffset.x, out mouseOffset.y);
            mouseOffset -= _winCenter;

            if (Math.Abs(mouseOffset.x + mouseOffset.y) < 0.01f)
            {
                return;
            }

            rotate((float)-mouseOffset.y / 10.0f, (float)-mouseOffset.x / 10.0f);
            Glfw.SetCursorPosition(_window, _winCenter.x, _winCenter.y);
        }
        public void InlineRGBA()
        {
            {
                var v0 = new dvec2(-4d, 2.5d);
                var v1 = 1.5d;
                var v2 = v0.r;
                v0.r = v1;
                var v3 = v0.r;

                Assert.AreEqual(v1, v3);

                Assert.AreEqual(1.5d, v0.x);
                Assert.AreEqual(2.5d, v0.y);

                Assert.AreEqual(-4d, v2);
            }
            {
                var v0 = new dvec2(9.5d, 2.5d);
                var v1 = 9d;
                var v2 = v0.g;
                v0.g = v1;
                var v3 = v0.g;

                Assert.AreEqual(v1, v3);

                Assert.AreEqual(9.5d, v0.x);
                Assert.AreEqual(9d, v0.y);

                Assert.AreEqual(2.5d, v2);
            }
            {
                var v0 = new dvec2(-7d, 3.5d);
                var v1 = new dvec2(-8.5d, 4.5d);
                var v2 = v0.rg;
                v0.rg = v1;
                var v3 = v0.rg;

                Assert.AreEqual(v1, v3);

                Assert.AreEqual(-8.5d, v0.x);
                Assert.AreEqual(4.5d, v0.y);

                Assert.AreEqual(-7d, v2.x);
                Assert.AreEqual(3.5d, v2.y);
            }
        }
        public void InlineXYZW()
        {
            {
                var v0 = new dvec2(5.5d, 8d);
                var v1 = new dvec2(-4.5d, 5.5d);
                var v2 = v0.xy;
                v0.xy = v1;
                var v3 = v0.xy;

                Assert.AreEqual(v1, v3);

                Assert.AreEqual(-4.5d, v0.x);
                Assert.AreEqual(5.5d, v0.y);

                Assert.AreEqual(5.5d, v2.x);
                Assert.AreEqual(8d, v2.y);
            }
        }
Exemple #27
0
 public void InvariantNorm()
 {
     {
         var v0 = new dvec2(-4.5d, -1d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(9.5d, -2d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(-3d, 3.5d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(6.5d, 8d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(-7d, 9.5d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(-8d, 8d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(2.5d, -9.5d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(-5d, 3.5d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(-5.5d, 8.5d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
     {
         var v0 = new dvec2(0.0, -9d);
         Assert.LessOrEqual(v0.NormMax, v0.Norm);
     }
 }
Exemple #28
0
 public void InvariantTriple()
 {
     {
         var v0 = new dvec2(-0.5d, -7.5d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(-6d, -2d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(3.5d, -5d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(-9.5d, 4d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(8d, 2d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(2.5d, 7.5d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(1.0, 4d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(-8.5d, -7.5d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(-1.5d, 9d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
     {
         var v0 = new dvec2(-5d, 6.5d);
         Assert.AreEqual(v0 + v0 + v0, 3 * v0);
     }
 }
Exemple #29
0
 public void InvariantIdNeg()
 {
     {
         var v0 = new dvec2(7.5d, -2.5d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(-2d, -5.5d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(-9.5d, -3d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(-5.5d, 9d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(0.5d, -6d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(7.5d, 7d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(1.0, -8.5d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(9d, -3.5d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(3.5d, 8.5d);
         Assert.AreEqual(v0, -(-v0));
     }
     {
         var v0 = new dvec2(-9.5d, 0.0);
         Assert.AreEqual(v0, -(-v0));
     }
 }
Exemple #30
0
 public void InvariantDouble()
 {
     {
         var v0 = new dvec2(6d, -2.5d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(2d, -0.5d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(4d, -8d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(-8d, -1d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(-3d, -1.5d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(7d, -6d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(3.5d, 8d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(0.5d, 6.5d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(5.5d, 5.5d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
     {
         var v0 = new dvec2(3d, 3d);
         Assert.AreEqual(v0 + v0, 2 * v0);
     }
 }
 /// <summary>Returns 1.0 if x &gt; 0, 0.0 if x = 0, or –1.0 if x &lt; 0.</summary>
 /// <returns>The sign of x</returns>
 protected static dvec2 sign(dvec2 x)
 {
     throw _invalidAccess;
 }
 public dvec3(double x, dvec2 yz)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Treats the first parameter c as a column vector (matrix with one column) 
 /// and the second parameter r as a row vector (matrix with one row) 
 /// and does a linear algebraic matrix multiply c * r, yielding a matrix 
 /// whose number of rows is the number of components in c and whose number 
 /// of columns is the number of components in r.
 /// </summary>
 /// <param name="c">left side column vector</param>
 /// <param name="r">right side row vector</param>
 /// <returns></returns>
 protected dmat4x2 outerProduct(dvec2 c, dvec4 r)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns y if y &lt; x, otherwise it returns x.</summary>
 protected internal static dvec2 Min(dvec2 x, dvec2 y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns x if x >= 0, otherwise it returns –x.</summary>
 /// <returns>The absolute value of x</returns>
 protected internal static dvec2 Abs(dvec2 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns true if x holds a NaN. Returns false otherwise.</summary>
 protected internal static bvec2 IsNaN(dvec2 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Computes and returns a*b + c.</summary>
 protected internal static dvec2 FusedMultiplyAdd(dvec2 a, dvec2 b, dvec2 c)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns a value equal to the nearest integer that is greater than or equal to x.</summary>
 protected internal static dvec2 Ceiling(dvec2 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns the reciprocal square root of x, i.e: 1/Sqrt(x)
 /// Results are undefined if x &lt;= 0 </summary>
 protected internal static dvec2 InverseSqrt(dvec2 x)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Treats the first parameter c as a column vector (matrix with one column) 
 /// and the second parameter r as a row vector (matrix with one row) 
 /// and does a linear algebraic matrix multiply c * r, yielding a matrix 
 /// whose number of rows is the number of components in c and whose number 
 /// of columns is the number of components in r.
 /// </summary>
 /// <param name="c">left side column vector</param>
 /// <param name="r">right side row vector</param>
 /// <returns></returns>
 protected dmat2x4 outerProduct(dvec4 c, dvec2 r)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns Min (Max (x, minVal), maxVal). Results are undefined if minVal > maxVal.</summary>
 protected internal static dvec2 Clamp(dvec2 x, dvec2 minVal, dvec2 maxVal)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns 0.0 if x &lt; edge0 and 1.0 if x &gt;= edge1 and
 /// performs smooth Hermite interpolation between 0 and 1 when edge0 &lt; x &lt; edge1.
 /// This is useful in cases where you would want a threshold function with a smooth
 /// transition.</summary>
 protected internal static dvec2 SmoothStep(dvec2 edge0, dvec2 edge1, dvec2 y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns x – Floor (x).</summary>
 protected internal static dvec2 Fraction(dvec2 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns 0.0 if x &lt; edge, otherwise it returns 1.0.</summary>
 protected internal static dvec2 Step(dvec2 edge, dvec2 y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns true if x holds a positive infinity or negative infinity. 
 /// Returns false otherwise.</summary>
 protected internal static bvec2 IsInfinity(dvec2 x)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns the distance between p0 and p1, i.e., Length (p0 – p1)</summary>
 protected internal static double Distance(dvec2 p0, dvec2 p1)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Selects which vector each returned component comes from. For a component of a that is false, 
 /// the corresponding component of x is returned. For a component of a that is true, 
 /// the corresponding component of y is returned. Components of x and y that are not selected 
 /// are allowed to be invalid floating point values and will have no effect on the results. 
 /// Thus, this provides different functionality than, for example,
 /// genType Lerp(genType x, genType y, genType(a)) where a is a Boolean vector.
 /// </summary>
 protected internal static dvec2 Lerp(dvec2 x, dvec2 y, bvec2 a)
 {
     throw _invalidAccess;
 }
 public dvec4(dvec2 xy, dvec2 zw)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns y if x &lt; y, otherwise it returns x.</summary>
 protected internal static dvec2 Max(dvec2 x, double y)
 {
     throw _invalidAccess;
 }
 public dvec4(double x, double y, dvec2 zw)
 {
     throw _invalidAccess;
 }
 /// <summary>For the incident vector I and surface normal N, and the ratio of indices 
 /// of refraction eta, return the refraction vector. 
 /// The result is computed by
 /// <code>
 /// k = 1.0 - eta * eta * (1.0 - Dot(N, I) * Dot(N, I))
 /// if (k &lt; 0.0)
 ///   return genType(0.0) // or genDType(0.0)
 /// else
 /// return eta * I - (eta * Dot(N, I) + Sqrt(k)) * N
 /// </code>
 /// The input parameters for the incident vector I and the surface normal N must 
 /// already be normalized to get thedesired results.</summary>
 protected internal static dvec2 Refract(dvec2 I, dvec2 N, double eta)
 {
     throw _invalidAccess;
 }
 public dvec4(dvec2 xy, double z, double w)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Splits x into a floating-point significand in the range [0.5, 1.0) 
 /// and an integral exponent of two, such that: x=significand⋅2**exponent
 /// The significand is returned by the function and the exponent is returned in the parameter exp. 
 /// For a floating-point value of zero, the significant and exponent are both zero. 
 /// For a floating-point value that is an infinity or is not a number, the results are undefined.
 /// </summary>
 protected static dvec2 frexp(dvec2 x, out ivec2 exp)
 {
     throw _invalidAccess;
 }
 public dvec4(double x, dvec2 yz, double w)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Builds a floating-point number from x and the corresponding integral exponent of two in exp, 
 /// returning: significand⋅2*+exponent
 /// If this product is too large to be represented in the floating-point type, the result is undefined.
 /// </summary>
 protected static dvec2 ldexp(dvec2 x, ivec2 exp)
 {
     throw _invalidAccess;
 }
 protected static dvec2 mod(dvec2 x, double y)
 {
     throw _invalidAccess;
 }
 /// <summary>For the incident vector I and surface orientation N,
 /// returns the reflection direction: 
 /// I – 2 * Dot(N, I) * N
 /// N must already be normalized in order to achieve the desired result..</summary>
 /// <param name="I">The incident vector</param>
 /// <param name="N">The normal to reflect around</param>
 /// <returns>The reflected vector</returns>
 protected internal static dvec2 Reflect(dvec2 I, dvec2 N)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns the fractional part of x and sets i to the integer part 
 /// (as a whole number floating point value). 
 /// Both the return value and the output parameter will have the same sign as x..</summary>
 protected static dvec2 mod(dvec2 x, out dvec2 y)
 {
     throw _invalidAccess;
 }
 /// <summary>Returns a value equal to the nearest integer to x. 
 /// A fractional part of 0.5 will round toward the nearest even integer. 
 /// (Both 3.5 and 4.5 for x will return 4.0.)</summary>
 protected internal static dvec2 RoundEven(dvec2 x)
 {
     throw _invalidAccess;
 }
 public dvec3(dvec2 xy, double z)
 {
     throw _invalidAccess;
 }