Example #1
0
        public Quat Vec3ToVec3(Vec3 _a, Vec3 _b)
        {
            Real angle      = Mathf.ACos(Vec3.DotProduct(_a, _b));
            Vec3 normal     = Vec3.CrossProduct(_a, _b);
            Real normal_len = normal.Length;

            return(new Quat(normal_len < 0.001f ? new Vec3(0, 1, 0) : normal *(1 / normal_len), angle));
        }
Example #2
0
        public Vec3 Rotate(Vec3 _v)
        {
            // nVidia SDK implementation

            Vec3 uv, uuv;
            Vec3 qvec = new Vec3(x, y, z);

            uv   = Vec3.CrossProduct(qvec, _v);
            uuv  = Vec3.CrossProduct(qvec, uv);
            uv  *= (2.0f * w);
            uuv *= 2.0f;

            return(_v + uv + uuv);
        }