返回介绍

Quaternion.operator * 相乘

发布于 2019-12-18 15:38:22 字数 2794 浏览 989 评论 0 收藏 0

JavaScript => public static operator *(lhs: Quaternion, rhs: Quaternion): Quaternion;
C# => public static Quaternion operator *(Quaternion lhs, Quaternion rhs);

Parameters 参数

lhsLeft-hand side quaternion
rhsRight-hand side quaternion.

Description 描述

Take the rotation state of lhs and apply a rotation of rhs.

获取lhs 的旋转状态并应用rhs的旋转。

Rotating by the product lhs * rhs is the same as applying the two rotations in sequence: lhs first and then rhs, relative to the reference frame resulting from lhs rotation. Note that this means rotations are not commutative, so lhs * rhs does not give the same rotation as rhs * lhs.

通过lhs * rhs产生的旋转是相同于按顺序逐一应用旋转:lhs 首先然后rhs,相对于从结果lhs旋转引用结构。注意这意味着旋转不是交替的,因此lhs * rhs不是指定相同的旋转作为rhs * lhs。

JavaScript:

#pragma strict
public var extraRotation: Transform;
// Applies the rotation of extraRotation to the current rotation.
transform.rotation *= extraRotation.rotation;

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public Transform extraRotation;
    // Applies the rotation of extraRotation to the current rotation.
    void Example() {
        transform.rotation *= extraRotation.rotation;
    }
}

JavaScript => public static operator *(rotation: Quaternion, point: Vector3): Vector3;
C# => public static Vector3 operator *(Quaternion rotation, Vector3 point);

Parameters 参数

Description 描述

Rotates the point point with rotation.

使用point和rotation一起旋转点。

JavaScript:

#pragma strict
// Moves the object along relativeDirection
// Usually you would use transform.Translate for this
public var relativeDirection: Vector3 = Vector3.forward;
function Update() {
	var absoluteDirection: Vector3 = transform.rotation * relativeDirection;
	transform.position += absoluteDirection * Time.deltaTime;
}

C#:

using UnityEngine;
using System.Collections;
 
// Moves the object along relativeDirection
// Usually you would use transform.Translate for this
public class ExampleClass : MonoBehaviour {
    public Vector3 relativeDirection = Vector3.forward;
    void Update() {
        Vector3 absoluteDirection = transform.rotation * relativeDirection;
        transform.position += absoluteDirection * Time.deltaTime;
    }
}

quaternion

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文