let u:number = point3d.x;
let v:number = point3d.y;
let w :number = point3d.z;
let T :number= Aplha;
let axisU:Vector3 ;
Vector3.normalize( vector3d,axisU);
let x:number= axisU.x;
let y:number= axisU.y;
let z:number= axisU.z;
let length:number= Math.sqrt(Vector3.dot(vector3d,vector3d));
let result:Vector3 = new Vector3();
result.x = u *Math.cos(T) + (y * w - z * v) *Math.sin(T) + x *(x * u + y * v + z * w)*( 1- Math.cos(T));
result.y = v *Math.cos(T) + (z * u - x * w) *Math.sin(T) + y *(x * u + y * v + z * w)*( 1- Math.cos(T));
result.z = w *Math.cos(T) + (x * v - y * u) *Math.sin(T) + z *(x * u + y * v + z * w)*( 1- Math.cos(T));
return result;
}
引擎API调用 方法
归一化旋转轴 是ac轴
Matrix4x4.createRotationAxis(归一化的旋转轴,旋转角度,结果矩阵);
Vector3.transformV3ToV3(AB向量,结果矩阵,AD向量);
1 个回复
Aar0n
赞同来自: sheen
vector3d为旋转轴ac轴, point3d为B点, 返回结果为D点
PointRoundVector( vector3d: Vector3, point3d: Vector3 , Aplha: number ): Vector3{
let u:number = point3d.x;
let v:number = point3d.y;
let w :number = point3d.z;
let T :number= Aplha;
let axisU:Vector3 ;
Vector3.normalize( vector3d,axisU);
let x:number= axisU.x;
let y:number= axisU.y;
let z:number= axisU.z;
let length:number= Math.sqrt(Vector3.dot(vector3d,vector3d));
let result:Vector3 = new Vector3();
result.x = u *Math.cos(T) + (y * w - z * v) *Math.sin(T) + x *(x * u + y * v + z * w)*( 1- Math.cos(T));
result.y = v *Math.cos(T) + (z * u - x * w) *Math.sin(T) + y *(x * u + y * v + z * w)*( 1- Math.cos(T));
result.z = w *Math.cos(T) + (x * v - y * u) *Math.sin(T) + z *(x * u + y * v + z * w)*( 1- Math.cos(T));
return result;
}
引擎API调用 方法
归一化旋转轴 是ac轴
Matrix4x4.createRotationAxis(归一化的旋转轴,旋转角度,结果矩阵);
Vector3.transformV3ToV3(AB向量,结果矩阵,AD向量);