MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / computePlaneAlignment

Function computePlaneAlignment

src/utils/sim3dAlignment.ts:113–127  ·  view source on GitHub ↗
(
  normal: [number, number, number],
  centroid: [number, number, number],
  targetUp: THREE.Vector3
)

Source from the content-addressed store, hash-verified

111 * and translates it to pass through the origin.
112 */
113export function computePlaneAlignment(
114 normal: [number, number, number],
115 centroid: [number, number, number],
116 targetUp: THREE.Vector3
117): Sim3d {
118 const normalVec = new THREE.Vector3(normal[0], normal[1], normal[2]).normalize();
119 const centroidVec = new THREE.Vector3(centroid[0], centroid[1], centroid[2]);
120
121 const rotation = new THREE.Quaternion().setFromUnitVectors(normalVec, targetUp.clone().normalize());
122 const rotatedCentroid = centroidVec.clone().applyQuaternion(rotation);
123 const distanceAlongAxis = rotatedCentroid.dot(targetUp);
124 const translation = targetUp.clone().multiplyScalar(-distanceAlongAxis);
125
126 return { rotation, translation, scale: 1 };
127}

Callers 3

align_save.test.tsFile · 0.85

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected