# Circumference of a Circle!

Hello All,

I need to get a circumference based on a circle diameter for my project.
There will be different diameters for each tubes that I need to calculate their circumference and put it to a formulation to calculate the wrapping of a fabric on it with the required lengths.

Sorry if there is a similar topic for this, but I would be appreciate if someone guide me to find whether there are any similar or exact topic which I am looking for.

By the way, I tried some formulation as in below screenshot but I cannot get the length of that circle when I try the division component as it gives me with the pi solution.
Don’t want to multiply 3,14 each time I change the radius size.
I will need to type an input from the diameter which will reduce my calculation method.

Kind Regards,
Bora Doker

Simply round your length (formula with pi).

Yep, sometimes you want one, sometimes the other. Whether or not numbers will be displayed as multiples of \pi is an option in the Grasshopper preferences. However you ideally don’t want to tie the behaviour of a single document to the Grasshopper application settings, since it might start behaving differently on different machines.

What you need to do here is specifically format the number so it looks exactly the way you want. You can do this using the Format component and a formatting mask like "{0:0.0000}" for guaranteed four decimal places, or "{0:0.0###}" for guaranteed one decimal place and up to three more provided they aren’t zeroes. Or even "{0.000}mm" if you want to include a unit code right away.

Sorry to bump this old one up again. I’m having the same issue - any “length” associated with a full circle simply comes up in units of Pi, rather than an actual length. Whats the solution to this?

Have you tried plugging it into a Number component?

Yes - plugging into a number component does the same thing. Oddly, plugging into an Integer component does what I would expect, however an integer’s rounding is not within the tolerances i need.

I am sorry why don’t you use the exact solutions already provided?

2 Likes
• like shynn sup and david rutten said.

• or alternatively you can create a c# node and put
A = C.ToNurbsCurve().GetLength();
in it after defining C as Circle with right click.

• or convert your circle to a curve before measuring the length.

Its been a bit of time since I’ve last been into GH, I’m not totally recognizing that (x,y) → R node shown in the photos above, would someone mind giving a name and/or quick explainer on it? I also tried to convert the circle/arc to a curve to measure but for some reason that just continues to return a (x * pi) result, is there another way to do this operation that I’m unaware of ?

In terms of coding, im trying to keep this to native base operations preferably… avoiding any plugins is ideal.

That’s alright.
Do tou mean the ‘Expression’ component?

You can input any formula by typing. It is basically a calculator. There are keywords that work as mathematical functions do:

Double click on it an it opens.
Click on f:N->R and you get a list of the functions

You can also make it return specific results when a criteria is met:

Expression component is native, as well as C# component.