Beispiel #1
0
    public static void CreateFromAffineTransform()
    {
        Assert.That(() => Matrix4x4.CreateFromAffineTransform(AffineTransform.Create(Quaternion.CreateFromAxisAngle(Vector3.UnitX, 0.5f), Vector3.One, Vector3.Zero)),
                    Is.EqualTo(Matrix4x4.Create(
                                   UnitX,
                                   Vector128.Create(0.0f, +0.87758255f, 0.47942555f, 0.0f),
                                   Vector128.Create(0.0f, -0.47942555f, 0.87758255f, 0.0f),
                                   UnitW
                                   ))
                    );

        Assert.That(() => Matrix4x4.CreateFromAffineTransform(AffineTransform.Create(Quaternion.Identity, Vector3.Create(1.0f, 2.0f, 3.0f), Vector3.Zero)),
                    Is.EqualTo(Matrix4x4.Create(
                                   UnitX,
                                   Vector128.Create(0.0f, 2.0f, 0.0f, 0.0f),
                                   Vector128.Create(0.0f, 0.0f, 3.0f, 0.0f),
                                   UnitW
                                   ))
                    );

        Assert.That(() => Matrix4x4.CreateFromAffineTransform(AffineTransform.Create(Quaternion.Identity, Vector3.One, Vector3.Create(1.0f, 2.0f, 3.0f))),
                    Is.EqualTo(Matrix4x4.Create(
                                   UnitX,
                                   UnitY,
                                   UnitZ,
                                   Vector128.Create(1.0f, 2.0f, 3.0f, 1.0f)
                                   ))
                    );
    }
    public static void ComponentsReturnCorrectValues(Quaternion rotation, Vector3 rotationOrigin, Vector3 scale, Vector3 translation)
    {
        var transform = AffineTransform.Create(rotation, scale, translation);

        Assert.That(transform.Rotation, Is.EqualTo(rotation));
        Assert.That(transform.Scale, Is.EqualTo(scale));
        Assert.That(transform.Translation, Is.EqualTo(translation));
    }
    public static void TransformsCompareNotEqual(Quaternion rotation, Vector3 rotationOrigin, Vector3 scale, Vector3 translation)
    {
        var a = AffineTransform.Create(rotation, scale, translation);
        var b = AffineTransform.Create(rotation, scale, translation);
        var c = AffineTransform.Create(rotation.WithY(1), scale, translation);

        Assert.That(a, Is.Not.EqualTo(c));
        Assert.That(a, Is.EqualTo(b));
    }
 void DisplayTrajectory()
 {
     try
     {
         AffineTransform worldRootTransform = AffineTransform.Create(targetJoints[0].position, targetJoints[0].rotation);
         DebugExtensions.DebugDrawTrajectory(worldRootTransform, sampleTrajectory, assetSampleRate, trajectoryColor, trajectoryColor);
     }
     catch (MissingReferenceException)
     {
         PreviewInvalidated?.Invoke();
     }
 }
 public AffineTransform Evaluate(float sampleTimeInSeconds)
 {
     return(AffineTransform.Create(
                positions.Evaluate(sampleTimeInSeconds),
                rotations.Evaluate(sampleTimeInSeconds)));
 }
 public                 AffineTransform this[int index] => AffineTransform.Create(positions[index], rotations[index]);
 AffineTransform GetAnchor(AffineTransform rootTransform, float distance, Camera camera)
 {
     return(AffineTransform.Create(rootTransform.t + (float3)camera.transform.right * distance, rootTransform.q));
 }