Blender Add on: circle inscriber
Dec, 2023
Dec, 2023
I have recently worked on a fabrication project for a class. I decided to build a fidget spinner as my final project for the class. However, that came with the added nuance of having to use a CNC vertical mill to make the fairly complicated circular cuts. As an ardent Blender enjoyer (not to be confused with the kitchen appliance), I decided it was a sane idea (tl;dr it wasn't) to use blender to model the fidget spinner first, obtain the coordinates for every cut from there and then pass it on to the CNC mill.
In a nutshell, a fidget spinner can be thought of as a series of intersecting circles of various sizes. below is my humble design for a fidget spinner
The problem is that for a CNC mill to make continuous arch cuts such as those in a fidget spinner, it needs every arch to have two endpoints, a center for a circle, and a radius for that circle. such that every two endpoints of every two consecutive circles are connected to the one before it and the one after it. That is every circle must be tangent to the one before it.
But here's the catch, the smaller three circles forming the three edges of the spinner were hand-placed between the three bigger circles, and while I can be sure that each circle touches the circle before it such that the arches are connected, there is no exact way to make sure that the next circle will also touch that circle at exactly one point.
Here's where the script comes into place, I needed to write a simple algorithm to inscribe a circle within two other circles such that the circle in the middle is tangent to the exterior circles.
This problem can be simplified further when the two encompassing circles will have the same radii, in this case, we know that the center of the new circle must exist on the line that bisects these two circles.
using the great equation of a line we and by using proportions, we can allow the user to input a float to determine how far from the center of the spinner (the origin point) do they want the center to be along that line. The method Create_point_on_Line does that for us
Finally we know that the radius of that small circle should be the difference between the distance between its center and the Big Circle center and the Radius of the Bigger circle "BigR"
The result can be seen in this figure where we add circles at random distances from the origin and it automatically ensures they fit exactly between the two circles!
In this project done for the Nasa Space Apps 2021 challenge, I intend to create a tool that allows users to visualize light curves of asteroids using unity engine, MatLab Plot library and alot of coding!
The amount of light emitted by Asteroids is insufficient to allow us to see their shapes. However, one of the few clues through which we can understand their shapes is their light curves. in the Light of this, an effective, practical, and simple-to-use tool to explore how an asteroid's shape affects its light curve has been developed. previous systems are extremely complex, and their user interfaces are extremely difficult to use. As a result, we created the ideal tool for understanding the light curves of asteroids and unraveling the mysteries of the Trojan asteroids in order to help researchers learn more about the origins of our solar system.
The project is mainly built using the Unity engine, we begin by extracting an image of every frame, combining the grayscale pixel values then sending these values to a text file to be graphed in python using the mat plot library. However, this solution proved too slow and the curve did not update in time resulting in a jagged line graph. We then opted to take these values and use them as position coordinates for an empty object with a trail component. This object is then visible to a separate graph camera that finally takes it and projects it into a render texture.
We use a simple implementation of the inverse square law for the deformation mechanism. Each vertex is given a velocity in its normal direction then the vertex starts being displaced until the damping reaches a maximum.
At its very essence, the idea is to use a random noise texture, that is a texture whose each pixel ranges from a black to white color, apply it to a 3D quad and use the colors as a gradient to determine the height of each vertex in 3D.
However, the result of this is a mesh that looks nothing like a real world terrain.
Fortunately, less random types of noise textures exist, a Perlin noise for instance provides a far more natural randomness. Perlin noise is an extremely powerful algorithm that is used often in procedural content generation.
One final thing I would like to discuss is how to process perlin noise to look more natural. Even though perlin noise does provide a certain degree of natural behavior, it doesn’t fully express the irregularities that one might expect in nature. For example, a terrain has large, sweeping features such as mountains, smaller features such as hills and depressions, even smaller ones such as boulders and large rocks, and very small ones like pebbles and minute differences in the terrain. The solution to this is simple: you take multiple noise functions with varying frequencies and amplitudes, and add them together. Of course, frequency refers to the period at which data is sampled, and amplitude refers to the range at which the result can be in.
The result of combining all of these iterations is a far more realistic wave:
The implementation of this in code is, in fact, very simple.
The result of this code is a natural gradient texture. I have begun by applying this texture to a "preview" quad and used a color gradient instead of the black and white image, where the color value depends on the "whiteness" of each pixel.
Here's a quick glimpse of the final project
The experience I am trying to evoke is of the vehicle's mesh being dented by the user. This requires that the vertices near the contact point are pushed into the surface. However, the deforming force doesn't have an inherent direction. It will be applied in all directions equally. This will cause vertices on a flat surface to be pushed apart, not pushed inward.
We can add a direction by pulling the force point away from the surface. A slight offset already guarantees that vertices are always pushed into the surface. The normal at the contact point can be used as the offset direction.
Because the process required that every vertices in the vehicle's and vehicle's collision mesh is affected, I refrained from using High-poly vehicle models available on the internet and decided to model my own custom mid-poly models of 20k vertices of a sedan and a hatchback, other vehicle types were also modeled but did not fair well.