Drawing an accurate circle with the spline tool

Hi there. I’m wondering if anyone can help me with drawing precise shapes using the spline tool. I’m having a lot of trouble with my current task; making an accurate circle. It seems as though such a simple task that I must be missing some vital knowledge; so I’ve turned to the Answerhub.

Any help is appreciated.

1 Like

Hey there,

I can’t guarantee these are precise circles but this is the solution I’ve come up with for creating circles for myself.

I am working in the Construction Script for my Blueprint so I’m not sure if this will work as well at run time.

Basically to start with you’ll need to create a variable called SplineRadius (Float) and for keeping it cleaner, SplineNum (Integer).

When you add the spline to your viewport make sure you tick “Closed Loop” in the details panel like below.

67121-loopsplinetick.png

Next we need to create the spline points. Below is how I went through and created the spline points with the SplineRadius variable.

Finally we need to alter the tangents to make the curve of the spline a circle. Now I’m sure there is some math you can do to ensure it is completely circle but my cheap easy way was to just get 1.5 X SplineRadius and just use the resulting float as the tangent.

Now in my example when I looped through all the variables the tangents were as follows:

Point 0 = Y Tangent with the returned 1.5 X Radius being Positive

Point 1 = X Tangent with the returned 1.5 X Radius being Negative

Point 2 = Y Tangent with the returned 1.5 X Radius being Negative

Point 3 = X Tangent with the returned 1.5 X Radius being Positive

How to set those tangents you can see in the image below.

You can of course fix the loop if you find a way, just couldn’t figure out a way to make sure that the returned 1.5 X Radius result went to the right tangent and it is easier to make sure you get it all right when it is laid out in full.

In the end you should get a result similar to what you seen below. Further more it means that you can edit the circle to what ever size you need by editing SplineRadius.

Anyways hope that helps. If you figure out the math for making sure that it is in fact a circle instead of my quick solution for the tangent let me know.

5 Likes

Thanks for sharing, that’s an interesting approach to it!

Could you explain why you multiply radius with factor 1.5?

It was simply the simplest approach for the best result I came up with at the time.
Basically a value of 1.5 gave consistent results that looks good.

i got the same question found this thread. 1.5 is not accurate enough for me, so i did some research and found this:

There is a math expression that calculates the correct value:

4 Likes

I have a question. If you wanted to put points in between each of those points how would you do it?

,

Thank you for the detailed explanation on how to set this up inside the construction script. It works exactly how you have it

,

Your addition was the final key to make it a perfect circle. Thanks again for posting this and helping us out here, I was slightly confused on how to get it in there so here is a complete picture for others, I created a variable named circle (float) and used that instead of 1.5, everything else was the same.

2 Likes

For the lazy:

I have reviewed the whole material implemented this thing using all the best parts of it here:

https://github.com/feureau/Blueprint-Recipe-Repository/tree/master/CircularSpline

I’m releasing it under GPL v3. Enjoy!

Thanks for the solution.

Just zipped it a bit to fill the screen for those as me :wink:

2 Likes

I thought I’d comment on this since I found a slightly better number to use.
In the math expression, change the 4 to 4.72 and you’ll get a smoother circle. I have a camera on my spline and it is very shaky at 4, but is much smoother at 4.72

UPDATE: So what I found was that even with the new number (4.72) my camera, although smoother, was still a bit wonky. For context I have a spherical planet in the center of my scene (0,0,0) and a camera on the spline orbiting it. So instead of having the camera rotate perpendicular to the vector of the spline, I just told the camera to look at world zero. This is simply done with a “Find Look at Rotation” node with your camera as the start and an object located at world zero as your target.
The one thing that needs to happen is that you need to set your location on spline before setting the rotation or else your camera will shake because it’s updating the location at the same time it’s updating the rotation.

or just use 1.651696 :slight_smile: thank fixed my wonky circles, thank you !

1 Like

I know this thread is old, but I just made this independently then decided to see how others did it.
This one I just made makes perfect circles with variable segments using good ol’ SIN and COS to create the circle.

So you can change the size and detail on the fly and it centers on the actor location.

Public Params:

Segments at 64

Segments lower:
343343-
And the Construction Script:

10 Likes

Where does this «1» come from? I don’t know why, but I think you just need to get rid of «3». So, k = 4 * tan(angle / 4). For 90° it will be k = 4 * tan(pi / 8) = 1.6568542494923801. You can confirm this by placing a cylinder and comparing the lines.

1 Like

Where does this «4.72» come from? I don’t know why, but I think you just need to get rid of «3». So, k = 4 * tan(angle / 4). For 90° it will be k = 4 * tan(pi / 8) = 1.6568542494923801. You can confirm this by placing a cylinder and comparing the lines.

I know this thread is old, but I solved this problem mathematically, so I believe it can be very helpful for everyone.

Function

This function takes inputs of a Spline, Segments, and Radius to calculate and draw a circle along the Spline.


In order to fit the content into one screenshot, I used two Math Expressions.

(360 - (360 / vSegments))
(4 * (tan(((D2R((360 / vSegments))) / 4))))

Preview

10 Segments

4 Segments

3 Segments

2 Segments

The computed values may be very large, which can be influenced by floating-point precision and may result in the circle appearing slightly more like an ellipse.

4 Likes

For future ppl, who need a circle:
Video on this topic

I did it with camera rail, should be fine with regular splines (I hope)

Thank you so much for posting this!
I followed this but skipped the tangent calculation in the end, the circle looks good without it if you have higher number of segments which I can afford.
I was looking for this math to make a procedural circular spring like coil using blueprint so the circle keeps going up in height and keeps coiling. I added a number of coils variable and opened up @Haikui 's 360 vsegment math expression node from above and did that manually while doing the appropriate multiplication to keep increasing segements as the coil number goes up. For good looking, I am using 8 segments per coil. Hope this helps someone!