mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-11 02:45:52 +01:00
extract radiusAtAngle to a function
This commit is contained in:
parent
2c824b88ce
commit
cfae03f291
1 changed files with 6 additions and 2 deletions
|
|
@ -52,10 +52,14 @@ export class Ellipse extends SketchObject {
|
|||
y = radius * Math.sin(angle);
|
||||
return {x, y, angle, radius};
|
||||
}
|
||||
|
||||
|
||||
radiusAtAngle(angle) {
|
||||
return Math.sqrt(1/( sq(Math.cos(angle)/this.radiusX) + sq(Math.sin(angle)/this.radiusY)))
|
||||
}
|
||||
|
||||
normalDistance(aim) {
|
||||
const polarPoint = this.toEllipseCoordinateSystem(aim);
|
||||
const L = Math.sqrt(1/( sq(Math.cos(polarPoint.angle)/this.radiusX) + sq(Math.sin(polarPoint.angle)/this.radiusY)));
|
||||
const L = this.radiusAtAngle(polarPoint.angle);
|
||||
return Math.abs(polarPoint.radius - L);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue