Creating a circle by three points in Blender

From the math course, we know that only one circle can be drawn through any three points in space. So, if we have three points in a Blender scene, defined by the coordinates V0 (x0, y0, z0), V1 (x1, y1, z1), and V2 (x2, y2, z2), let’s see how we can construct a circle that passes through these three points.

Any three points in space could be defined by three Ico Sphere objects placed in our 3D scene.

Get their coordinates.

To create a circle that passes through these three points, we need to find two of its parameters: center and radius.

The center of the circle can be found as the center of the sphere on whose surface all three initial points lie. Also, all four points (the three initial points and the center of the sphere) must lie in the same plane.

We can write a system of equations for three spheres passing through three given points, as well as a system of equations describing the belonging of points to the same plane. Having solved this system of equations, we can find the values ​​of the center of the sphere and its radius that we need.

Let’s skip the mathematical transformations and go straight to the algorithm with the code.

Note that for the convenience of calculating the coefficients of the equation, we defined a function for calculating the pseudo-dot-product of one vector by another: _dot(). As a result, we get a number equal to the sum of the squares of the corresponding coordinates of the multiplied vectors.

Having calculated the coordinates of the center of the circle and its radius, we can now add a circle to the scene – a Circle object. We place a 3D cursor at the point where the center of the circle should be located and call the operator for adding the circle to the scene.

The circle is in the right place, but it still does not pass through the three points we need.

This is because the circle is always added to the scene so that it is located horizontally – in the XY plane.

In order for the circle to lie on the original three points plane, it must be rotated so that its normal coincides with the normal of the plane formed by the three original points. We can do this by calculating the rotation matrix of the circle’s normal vector to the normal vector of the plane of the three points.

Normal to the plane formed by three points

And the normal of the circle

Using one of the functions for calculating the rotation matrix from one vector to another, we get the matrix we need.

Now we can rotate the circle using the calculated matrix.

And now the circle passes through all three initially points.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments