我试图在一个球面上建立一个切平面,这个切平面在Three.js (v0.129)中穿过球体表面上的特定点。我的算法如下:
H 210G 211但由于某种原因,乘积并不总是垂直于半径和法向量。我不明白为什么,我试着为所有的向量建立线来可视化它,我得到了以下信息:

问题是我做错了什么?还是有更好的方法通过给定的点构造切平面到球面?
我的代码如下:
const createTangentPlane = (point: THREE.Vector3, sphere: Entity) => {
sphere.object3D.updateMatrixWorld();
sphere.object3D.updateMatrix();
const center = sphere.object3D.position;
const radiusVector = new THREE.Vector3().subVectors(point, center).normalize();
const radiusNormal = radiusVector
.clone()
.applyAxisAngle(new THREE.Vector3(0, 0, 1), Math.PI * 0.5)
.normalize();
const a = radiusNormal.clone().normalize().setLength(10).add(point);
const b = radiusNormal.clone().normalize().negate().setLength(10).add(point);
const orthogonalVector = radiusVector.clone().cross(radiusNormal);
const a1 = orthogonalVector.clone().setLength(10).add(point);
const b1 = orthogonalVector.clone().negate().setLength(10).add(point);
createLine(([a1, b1]);
createLine([a, b]);
createLine([center, point]);
//createPlaneFrom4Points([a, a1, b1, b]);
}发布于 2021-07-26 13:35:17
给予:
three.js r130 (r129应该很好),,
Vector3))
假设:
球体位置在世界coordinates
中。
let normal = new THREE.Vector3().copy( tangentPoint )
normal.sub( sphere.position ) // remove sphere translation
let plane = new THREE.Mesh(
new THREE.PlaneGeometry( sphere.radius, sphere.radius )
new THREE.MeshBasicMaterial( { color: 'red' } )
)
plane.lookAt( normal )
plane.position.copy( tangentPoint )https://stackoverflow.com/questions/68527609
复制相似问题