示例#1
0
        public void Add(IPoint4 p, IVector4 v)
        {
            ITuple4_Double _p = p.AsTupleDouble();
            ITuple4_Double _v = v.AsTupleDouble();

            this.Set(_p.X + _v.X, _p.Y + _v.Y, _p.Z + _v.Z, _p.W + _v.W);
        }
示例#2
0
        public void Add(IVector4 v1, IVector4 v2)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(_v1.X + _v2.X, _v1.Y + _v2.Y, _v1.Z + _v2.Z, _v1.W + _v2.W);
        }
示例#3
0
        public void SimpleMul(IVector4 v1, IVector4 v2)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(_v1.X * _v2.X, _v1.Y * _v2.Y, _v1.Z * _v2.Z, _v1.W * _v2.W);
        }
示例#4
0
        public void ProjectTo(IVector4 where)
        {
            BuffVector4d aux = new BuffVector4d(where);

            aux.ProjV(new Vector4d(this.x, this.y, this.z, this.w));
            this.Set(aux.X, aux.Y, aux.Z, aux.W);
        }
示例#5
0
        public void Sub(IPoint4 p, IVector4 v)
        {
            ITuple4_Double _p = p.AsTupleDouble();
            ITuple4_Double _v = v.AsTupleDouble();

            this.Set(_p.X - _v.X, _p.Y - _v.Y, _p.Z - _v.Z, _p.W - _v.W);
        }
示例#6
0
        public void Sub(IVector4 v1, IVector4 v2)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(_v1.X - _v2.X, _v1.Y - _v2.Y, _v1.Z - _v2.Z, _v1.W - _v2.W);
        }
示例#7
0
 public static Vector4d ToVector4d(this IVector4 p)
 {
     if (p is Vector4d)
     {
         return((Vector4d)p);
     }
     return(new Vector4d(p));
 }
示例#8
0
        public void ProjectTo(IPoint4 p1, IVector4 where)
        {
            ITuple4_Double _p1 = p1.AsTupleDouble();
            BuffVector4d   aux = new BuffVector4d(where);

            aux.ProjV(new Vector4d(_p1.X, _p1.Y, _p1.Z, _p1.W));
            this.Set(aux.X, aux.Y, aux.Z, aux.W);
        }
示例#9
0
        public BuffVector4d(IVector4 other)
        {
            ITuple4_Double _other = other.AsTupleDouble();

            this.x = _other.X;
            this.y = _other.Y;
            this.z = _other.Z;
            this.w = _other.W;
        }
示例#10
0
        public void Lineal(IVector4 v2, double alpha, double beta)
        {
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(alpha * this.x + beta * _v2.X,
                     alpha * this.y + beta * _v2.Y,
                     alpha * this.z + beta * _v2.Z,
                     alpha * this.w + beta * _v2.W);
        }
示例#11
0
        public Vector4d(IVector4 v)
        {
            ITuple4_Double _v = v.AsTupleDouble();

            this.X = _v.X;
            this.Y = _v.Y;
            this.Z = _v.Z;
            this.W = _v.W;
        }
示例#12
0
        public static ITuple4_Double AsTupleDouble(this IVector4 v)
        {
            ITuple4_Double ret = v as ITuple4_Double;

            if (ret != null)
            {
                return(ret);
            }
            return(VectorUtils.Convert <ITuple4_Double>(v));
        }
示例#13
0
        public double InvLerp(IVector4 v2, IVector4 vLerp)
        {
            BuffVector4d v12 = new BuffVector4d(v2);

            v12.Sub(this);
            BuffVector4d v1Lerp = new BuffVector4d(vLerp);

            v1Lerp.Sub(this);
            return(v12.Proj(v1Lerp));
        }
示例#14
0
        public void Lineal(IVector4 v1, IVector4 v2, double alpha, double beta)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(alpha * _v1.X + beta * _v2.X,
                     alpha * _v1.Y + beta * _v2.Y,
                     alpha * _v1.Z + beta * _v2.Z,
                     alpha * _v1.W + beta * _v2.W);
        }
示例#15
0
        public Vector4F(IVector4 <float> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            X = source.X;
            Y = source.Y;
            Z = source.Z;
            W = source.W;
        }
示例#16
0
        public void Update()
        {
            Assert.True(_lights.Count <= MaxLightCount);

            var vec  = (Vector4 *)_pointer;
            var ivec = (IVector4 *)_pointer;

            vec[0]  = new Vector4(CameraPosition);
            vec[1]  = new Vector4(Ambient);
            ivec[2] = new IVector4(_lights.Count, LightCastingShadowNumber, 0, 0);

            for (int i = 0; i < _lights.Count; i++)
            {
                var l = _lights[i];
                var p = _pointer + 48 + i * BytesInLight;

                vec = (Vector4 *)(p);

                vec[0] = new Vector4(l.Position);
                vec[1] = new Vector4(-l.Direction);
                vec[2] = new Vector4(l.Diffuse);
                vec[3] = new Vector4(l.Attenuation);

                var type = (int *)(p + BytesInLight - 4);
                type[0] = (int)l.Type;
            }

            if (Context.DirectStateAccess)
            {
                Context.BufferSubData(Handle, 0, SizeInBytes, _pointer);
            }
            else
            {
                Context.BindUniformBuffer(Handle);
                Context.BufferSubData(BindBufferTarget.UniformBuffer, 0, SizeInBytes, _pointer);
            }
        }
示例#17
0
 public double Proj(IVector4 v2)
 {
     return(this.Dot(v2) / this.Length);
 }
示例#18
0
        public double Dot(IVector4 v2)
        {
            ITuple4_Double _v2 = v2.AsTupleDouble();

            return(this.X * _v2.X + this.Y * _v2.Y + this.Z * _v2.Z + this.W * _v2.W);
        }
示例#19
0
        public bool Equals(IVector4 other)
        {
            ITuple4_Double _other = other.AsTupleDouble();

            return(this.Equals(_other.X, _other.Y, _other.Z, _other.W));
        }
示例#20
0
        public bool EpsilonEquals(IVector4 other, double epsilon = EPSILON)
        {
            ITuple4_Double _other = other.AsTupleDouble();

            return(this.EpsilonEquals(_other.X, _other.Y, _other.Z, _other.W, epsilon));
        }
示例#21
0
 public void ProjV(IVector4 v1, IVector4 v2)
 {
     this.Mul(v1, this.Proj(v2));
 }
示例#22
0
        public void Mul(IVector4 v1, double c)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();

            this.Set(_v1.X * c, _v1.Y * c, _v1.Z * c, _v1.W * c);
        }
示例#23
0
 public void Lerp(IVector4 v1, IVector4 v2, double alpha)
 {
     this.Lineal(v1, v2, 1 - alpha, alpha);
 }
示例#24
0
        public void Abs(IVector4 v1)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();

            this.Set(Math.Abs(_v1.X), Math.Abs(_v1.Y), Math.Abs(_v1.Z), Math.Abs(_v1.W));
        }
示例#25
0
        public void Neg(IVector4 v1)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();

            this.Set(-_v1.X, -_v1.Y, -_v1.Z, -_v1.W);
        }
示例#26
0
        public double Dot(IVector4 v2)
        {
            ITuple4_Double _v2 = v2.AsTupleDouble();

            return(this.x * _v2.X + this.y * _v2.Y + this.z * _v2.Z + this.w * _v2.W);
        }
示例#27
0
        public void Add(IVector4 v2)
        {
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(this.x + _v2.X, this.y + _v2.Y, this.z + _v2.Z, this.w + _v2.W);
        }
示例#28
0
        public void Div(IVector4 v1, double c)
        {
            ITuple4_Double _v1 = v1.AsTupleDouble();

            this.Set(_v1.X / c, _v1.Y / c, _v1.Z / c, _v1.W / c);
        }
示例#29
0
        public void SimpleMul(IVector4 v2)
        {
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(this.x * _v2.X, this.y * _v2.Y, this.z * _v2.Z, this.w * _v2.W);
        }
示例#30
0
        public void Sub(IVector4 v2)
        {
            ITuple4_Double _v2 = v2.AsTupleDouble();

            this.Set(this.x - _v2.X, this.y - _v2.Y, this.z - _v2.Z, this.w - _v2.W);
        }