コード例 #1
0
        public CubicSphericalCurve(Vector3D center, MatrixD from, MatrixD to)
        {
            var tmp          = new CubicCurve(from, to);
            var avgSpherical = Vector3D.Normalize((from.Translation + to.Translation) / 2 - center);
            var quat         = QuaternionD.CreateFromTwoVectors(avgSpherical, new Vector3D(1, 0, 0));
            var m            = MatrixD.CreateFromQuaternion(quat);

            m       = MatrixD.CreateTranslation(-center) * m;
            _matrix = MatrixD.Invert(m);
            _curve  = new CubicCurve(SphericalExtensions.ToSpherical(Vector3D.Transform(tmp.P0, m)),
                                     SphericalExtensions.ToSpherical(Vector3D.Transform(tmp.P1, m)),
                                     SphericalExtensions.ToSpherical(Vector3D.Transform(tmp.P2, m)),
                                     SphericalExtensions.ToSpherical(Vector3D.Transform(tmp.P3, m)));
        }
コード例 #2
0
 public Vector3D SampleDerivative(float t)
 {
     return(Vector3D.TransformNormal(
                SphericalExtensions.DifferentialFromSpherical(_curve.Sample(t), _curve.SampleDerivative(t)), _matrix));
 }
コード例 #3
0
 public Vector3D Sample(float t)
 {
     return(Vector3D.Transform(SphericalExtensions.FromSpherical(_curve.Sample(t)), _matrix));
 }