public static Vector3 Cross (Vector3 lhs, Vector3 rhs);

Description

两个向量的叉积。

两个向量的叉积生成第三个向量, 该向量垂直于两个输入向量。结果的大小等于: 将两个输入的大小相乘,然后乘以输入之间角度的正弦值。 可以使用“左手规则”确定结果向量的方向。


The left hand rule applied to Cross(a, b).

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { // Get the normal to a triangle from the three corner points, a, b and c. Vector3 GetNormal(Vector3 a, Vector3 b, Vector3 c) { // Find vectors corresponding to two of the sides of the triangle. Vector3 side1 = b - a; Vector3 side2 = c - a;

// Cross the vectors to get a perpendicular vector, then normalize it. return Vector3.Cross(side1, side2).normalized; } }