コード例 #1
0
        public void ClampLength()
        {
            //too long
            Vector v1 = new Vector(0, 6);
            Vector v2 = VectorUtil.ClampLength(v1, 1, 5);

            Assert.AreEqual(new Vector(0, 5), v2);

            //too short
            Vector v3 = new Vector(0, 0.5);
            Vector v4 = VectorUtil.ClampLength(v3, 1, 5);

            Assert.AreEqual(new Vector(0, 1), v4);

            //just right
            Vector v5 = new Vector(0, 4);
            Vector v6 = VectorUtil.ClampLength(v5, 1, 5);

            Assert.AreEqual(new Vector(0, 4), v6);
        }