Yuka.js库中的Vector3类的方法,用于从球面坐标系中的极角和方位角创建一个三维向量。
Vector3.fromSpherical(radius, phi, theta);
radius:球面坐标的半径,类型为number。phi:球面坐标的极角,也称为仰角,类型为number,以弧度为单位。theta:球面坐标的方位角,也称为方位角,类型为number,以弧度为单位。球面坐标系中指定半径、极角、方位角的三维向量。
const radius = 10;
const phi = Math.PI / 4; // 仰角45度
const theta = Math.PI / 2; // 方位角90度
const vector = Vector3.fromSpherical(radius, phi, theta);
console.log(vector); // 输出 Vector3 { x: 0, y: 7.071067811865476, z: 7.071067811865476 }
球面坐标系中,radius表示半径,phi表示仰角,取值范围为[0, π],theta表示方位角,取值范围为[0, 2π]。该方法将球面坐标系中的点表示为笛卡尔坐标系中的向量。