public override void Translate(float Ox, float Oy, float Oz)
        {
            float[] p1   = LightPos;
            _Affine tran = new _Affine();

            tran.Translate(Ox, Oy, Oz);
            p1 = tran.ConvertPoint(p1);
            _Math3D.CopyMatrix(LightPos, p1);
            ChangeMatrix();
        }
        public override void Rotate(float Angle, float Ox, float Oy, float Oz)
        {
            float[] p1  = LightPos;
            _Affine rot = new _Affine();

            rot.Rotate(Angle, Ox, Oy, Oz);
            p1 = rot.ConvertPoint(p1);
            _Math3D.CopyMatrix(LightPos, p1);
            ChangeMatrix();
        }
Пример #3
0
        // Quay quanh truc bat ky
        public void Rotate(float angle, _Vector3D p0, _Vector3D p1)
        {
            _Vector3D v     = p1 - p0;
            _Affine   tran1 = new _Affine();
            _Affine   rot   = new _Affine();
            _Affine   tran2 = new _Affine();

            tran1.Translate(-p0.x, -p0.y, -p0.z);
            rot.Rotate(angle, v);
            tran2.Translate(p0.x, p0.y, p0.z);
            _Affine temp = tran1 + rot + tran2;

            _Math3D.CopyMatrix(mMatrix, temp.mMatrix);
        }
Пример #4
0
        public static _Affine operator+(_Affine T1, _Affine T2)
        {
            _Affine result = new _Affine();

            for (int i = 0; i < 4; ++i)
            {
                for (int j = 0; j < 4; ++j)
                {
                    result[i * 4 + j] =
                        T1[i * 4] * T2[j] +
                        T1[i * 4 + 1] * T2[4 + j] +
                        T1[i * 4 + 2] * T2[2 * 4 + j];
                }
            }
            return(result);
        }
Пример #5
0
        public override void Translate(float Ox, float Oy, float Oz)
        {
            float[] p1 = new float[3] {
                pBegin.x, pBegin.y, pBegin.z
            };
            float[] p2 = new float[3] {
                pEnd.x, pEnd.y, pEnd.z
            };
            _Affine tran = new _Affine();

            tran.Translate(Ox, Oy, Oz);
            p1     = tran.ConvertPoint(p1);
            p2     = tran.ConvertPoint(p2);
            mBegin = new _Vector3D(p1);
            mEnd   = new _Vector3D(p2);
            ChangeMatrix();
        }
Пример #6
0
        public override void Rotate(float Angle, float Ox, float Oy, float Oz)
        {
            float[] p1 = new float[3] {
                pBegin.x, pBegin.y, pBegin.z
            };
            float[] p2 = new float[3] {
                pEnd.x, pEnd.y, pEnd.z
            };
            _Affine rot = new _Affine();

            rot.Rotate(Angle, Ox, Oy, Oz);
            p1     = rot.ConvertPoint(p1);
            p2     = rot.ConvertPoint(p2);
            mBegin = new _Vector3D(p1);
            mEnd   = new _Vector3D(p2);
            ChangeMatrix();
        }
Пример #7
0
        // Ham tinh lai ma tran cua vector khi co su thay doi vi tri 2 dau cua vector
        private void ChangeMatrix()
        {
            // Di chuyen hinh den vi tri tuong ung
            Center[0] = 0;
            Center[1] = 0;
            Center[2] = 0;
            _Affine Iden = new _Affine();

            Iden.Identity();
            Matrix = (float[])Iden;
            _Vector3D v1     = new _Vector3D(0, 0, 1);
            _Vector3D v2     = pEnd - pBegin;
            _Vector3D Normal = _Math3D.FindNormalVector(v1, v2);
            double    rad    = _Math3D.GetAngleBetweenVectors(v1, v2);

            if (Normal.x != 0 || Normal.y != 0 || Normal.z != 0)
            {
                base.Rotate((float)(rad * 180 / Math.PI), Normal.x, Normal.y, Normal.z);
            }
            base.Translate(pBegin.x - Center[0], pBegin.y - Center[1], pBegin.z - Center[2]);
        }
Пример #8
0
 public _Affine(_Affine P)
 {
     mMatrix = new float[16];
     _Math3D.CopyMatrix(mMatrix, P.mMatrix);
 }