Last active
July 28, 2020 07:43
-
-
Save AEnMe/01066da25bb211ee4cd3acb7646cd2a0 to your computer and use it in GitHub Desktop.
Drawing conic tangents on ellipse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
poz = content("Group 1").transform.position; // Cicrle Position | |
centre= [0,0]; // PIVOT POINT | |
cx = poz[0]; | |
cy = poz[1]; | |
diametre = content("Group 1").content("Ellipse Path 1").size; | |
r = diametre[1] / 2; | |
P = length( centre , [Math.abs(cx), Math.abs(cy)]); | |
// ZEROED // | |
if ( P < r) { | |
draw = [centre,centre]; | |
} else { | |
// TRIGO // | |
hyp = P; | |
adj = r; | |
opp = Math.sqrt(P * P - r * r); | |
Cos = adj / hyp; | |
Sin = opp / hyp; | |
// PATH // | |
p = []; | |
a = [-Cos, Sin] * r + poz; | |
b = [-Cos, -Sin] * r + poz; | |
function rotate(x, y) { | |
A = -(Math.atan2(cy, cx)); // radian | |
cos = Math.cos(A), | |
sin = Math.sin(A), | |
nx = (cos * (x - cx)) + (sin * (y - cy)) + cx; | |
ny = (cos * (y - cy)) - (sin * (x - cx)) + cy; | |
return [nx, ny]; | |
} | |
a = rotate(a[0], a[1]); | |
b = rotate(b[0], b[1]); | |
draw = [centre, a, b]; | |
} | |
createPath(draw); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment