@three3d/tools
Version:
@three3d/tools 提供了 ThreeJS 常用的工具库
80 lines • 2.59 kB
TypeScript
import type { Vector3 } from "three";
/**
* 计算两个向量的夹角
* @remarks
* 与 `Vector3.angleTo(v)` 不同的是:当 from 或 to 为零时,会返回 0
* @param from - 起始向量
* @param to - 目标向量
* @returns 返回一个 0 到 pi(弧度)的数值
*/
export declare function getIncludedAngle(from: Vector3, to: Vector3): number;
/**
* 以轴 refAxis 为参考轴,获取从向量 from 到 向量 to 的旋转角度
* @remarks
* 参考轴只提供大致的方向;最终计算的旋转角度不是以参考轴为旋转轴的,而是以垂直于 from 和 to 的轴为旋转轴的;
*
* 以逆时钟方向为旋转正方向
* @param from - 起始向量
* @param to - 结束向量
* @param refAxis - 参考轴;
* @returns
*/
export declare function getRotationAngle(from: Vector3, to: Vector3, refAxis: Vector3): number;
/**
* 以轴 axis 为旋转轴,获取从向量 from 到 向量 to 的旋转角度
* @remarks
* 与 {@link getRotationAngle} 区别是:
* - getRotationAngle 计算的是 从向量 from 到向量 to 旋转角度
* - getAxisRotationAngle 计算的是 向量 from 和 向量 to 在垂直于旋转轴 axis 平面上的投影的旋转角度;即:以 axis 为旋转轴的旋转角度
*
* 以逆时钟方向为旋转正方向
* @param from - 起始向量
* @param to - 结束向量
* @param axis - 旋转轴;
* @returns
*/
export declare function getAxisRotationAngle(from: Vector3, to: Vector3, axis: Vector3): number;
/**
* 航向角
*
* @remarks
* 所有角度都是以逆时针方向为正方向
*/
export interface YawPitchRoll {
/**
* 偏航角
* @remarks
* - 旋转轴 上方向量
* - 起始向量:前方向量
*/
yaw: number;
/**
* 俯仰角
* @remarks
* - 旋转轴 右方向量
* - 起始向量:前方向量
*/
pitch: number;
/**
* 横滚角
* @remarks
* - 旋转轴 后方向量
* - 起始向量:上方向量
*/
roll: number;
}
/**
* 获取方位角:即:偏航角、俯仰角、横滚角
* @remarks
* 以 front 为前方,以 up 为上方,计算 target 的 偏航角、俯仰角、横滚角
*
* 这些角度都是在各个轴上的投影旋转,各个轴相互独立,互不影响
*
*
* @param target - 目标向量
* @param front - 表示前方的向量
* @param up - 表示上方的向量
* @returns 返回 {@link YawPitchRoll}
*/
export declare function getAzimuthAngle(target: Vector3, front: Vector3, up: Vector3): YawPitchRoll;
//# sourceMappingURL=angle.d.ts.map