 # How to Create a arc through 3 points with maxscript?

#1

How to Create a arc through 3 points with maxscript?

#2

I want create a arc with 3 points .Then I can redawn the dwg quickly. How can I realize that?

#3

for those particular solutions thats 3 points and 2 tangents btw or are we talking circle fitting ?

#4

for the latter… something like this ?

``````fn intersection2d p1 r1 p2 r2 =
(
dx = p2.x - p1.x, dy = p2.y - p1.y;
det = r2.x * r1.y - r2.y * r1.x;
p1 + r1 * (dy * r2.x - dx * r2.y) / det;
)

fn make_arc a b c =
(
ab = b - a;
bc = c - b;
mab = a + 0.5 * ab;
mbc = b + 0.5 * bc;

ab = normalize ab
bc = normalize bc
r1 = [-ab.y, ab.x, ab.z];
r2 = [-bc.y, bc.x, bc.z];

p = intersection2d mab r1 mbc r2;
r = distance p a;
arc radius:r pos:p from:(180 + (atan2 (p.y - c.y) (p.x - c.x))) to:(180 + (atan2 (p.y - a.y) (p.x - a.x)))
)
``````

where a, b and c are the 3 positions in world space, we don’t check for parallel lines in the intersection by the way so if a b c are colinear there’s going to be trouble #5

Very nice work! You got it working in a few lines of code. Thank you very much.

#6

thanks, you could add a `dot ab bc == 1.0` test and if true create a line instead…

``````sp = splineshape();