mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-14 20:33:30 +01:00
fix ellipse picking
This commit is contained in:
parent
16063c9f56
commit
0dc159eb1f
1 changed files with 2 additions and 2 deletions
|
|
@ -45,7 +45,7 @@ export class Ellipse extends SketchObject {
|
|||
toEllipseCoordinateSystem(point) {
|
||||
let x = point.x - this.centerX;
|
||||
let y = point.y - this.centerY;
|
||||
const angle = Math.atan2(y, x) - this.rotation;
|
||||
const angle = Math.atan2(y, x) + this.rotation;
|
||||
const distance = math.distance(0, 0, x, y);
|
||||
x = distance * Math.cos(angle);
|
||||
y = distance * Math.sin(angle);
|
||||
|
|
@ -55,7 +55,7 @@ export class Ellipse extends SketchObject {
|
|||
normalDistance(aim) {
|
||||
const trInfo = this.toEllipseCoordinateSystem(aim);
|
||||
const sq = (a) => a * a;
|
||||
const L = Math.sqrt(1/( sq(Math.sin(trInfo.angle)/this.radiusX) + sq(Math.cos(trInfo.angle)/this.radiusY)));
|
||||
const L = Math.sqrt(1/( sq(Math.cos(trInfo.angle)/this.radiusX) + sq(Math.sin(trInfo.angle)/this.radiusY)));
|
||||
return Math.abs(trInfo.distance - L);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue