Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Centre of circle
- vec2 ctr;
- // Intersection tangents (or just p1-p0 and p2-p1)
- vec2 tan1;
- vec2 tan2;
- // Get normal angles (ie. which angle points towards the intersection point)
- var ang1 = atan2(tan1.y, tan1.x) - PI/2;
- var ang2 = atan2(tan2.y, tan2.x) - PI/2;
- // Get delta between angles
- var angD = ang2 - ang1;
- angD -= 2PI * round(angD / 2PI);
- // Calculate number of segment points
- // (5 points per 180 degree turn)
- int segC = abs(angD) / (PI/5);
- for (int a=0; a<segC; ++a) {
- // Stepping angle between the intersection points
- var ang = ang1 + angD * a / (segC - 1);
- // Calculate new vectors
- var tan = vec2(cos(ang), sin(ang));
- var nrm = vec2(-sin(ang), cos(ang));
- points.Add(ctr + tan * Radius - nrm * Width);
- points.Add(ctr + tan * Radius + nrm * Width);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement