Skip to content

Commit

Permalink
Fixed ellipsoid normals
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm committed Sep 18, 2023
1 parent 2dfa5c2 commit 1b5462f
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/structure/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,14 @@ export class Ellipsoid extends Shape {
const newVertex: XYZ = rotateAndPlace(v, this.orientation, this.position);
vertices.push(newVertex);

const relativeVertex = subXYZ(newVertex, this.position);
const newNormal: XYZ = {
/*
I think these are wrong because the vertex has now been rotated so it's not aligned with the axes
x: relativeVertex.x / Math.pow(this.semiaxes[0], 2.0),
y: relativeVertex.y / Math.pow(this.semiaxes[1], 2.0),
z: relativeVertex.z / Math.pow(this.semiaxes[2], 2.0),
*/
// this is also wrong, but possibly less wrong.
x: relativeVertex.x,
y: relativeVertex.y,
z: relativeVertex.z,
};
// the normal to the ellipsoid surface is best computed in the original
// coordinate system, and then rotated in place
const newNormal: XYZ = rotateAndPlace({
x: v.x / Math.pow(this.semiaxes[0], 2.0),
y: v.y / Math.pow(this.semiaxes[1], 2.0),
z: v.z / Math.pow(this.semiaxes[2], 2.0),
}, this.orientation, {x:0, y:0, z:0});

normals.push(newNormal);
}
return {
Expand Down

0 comments on commit 1b5462f

Please sign in to comment.