# Component: Circle From 2 Points & Radius

Edit: spelling
I needed a component “Circle From Two Points and a Radius” and couldn’t find one, so I made one myself. I figured someone else may also have use for it so I upload it here.

The Circle center can land on either side of the line A–>B. Default is on the Right side (as illustrated below). The F input Flips the circle to land on the other side.

The component outputs a Circle and it’s Circle Center.

The math is a bit ugly but someone smarter than me perhaps can hint about a simplification.

Fig. A C# Component and a GH definition doing the same thing.

The GH definition

// Rolf

5 Likes

I’m not on a PC right now so I don’t know if you used polar coordinates. An algorithm with those I have in mind is like so:

• create a transformation T remapping A and B to a coordinate system with the origin in A and the x-axis AB and transform A and B
• calculate the height h of the triangle ABCC h = \sqrt{r^2 - \frac{(AB)^2}{4}}
• calculate the angle \alpha formed between AB and ACC \sin{\alpha} = \frac{h}{r}
• define a polar coordinate system with origin in A and zero rotation parallel to AB
• construct CC_{\alpha} in polar coordinates CC_{\alpha} = (r,-\alpha)
• calculate the carthesian coordinates of CC, since we chose our cathesian and polar coordinate systems conveniently, this is quite simple: CC = (r\cos{-\alpha},r\sin{-\alpha})
• Transform CC back to the original coordinate system by transforming with T^{-1}

There are probably some sign errors in the math, but in theory this should work and be quite fast to calculate.

2 Likes

You didn’t internalize your points? And your “GH Version - Same Logic” group doesn’t actually draw the circle or respond to the ‘Flip’ toggle.

I added a random two points group (yellow) and two GH versions. The first one draws both circles and disregards the right/left issue - very simple:

The second one implements the right/left/‘Flip’ feature and behaves exactly like your C# component.