|
|
Disclaimer: This post doesn't contain a question. It is about something I've
found out. Not something that'll be significant for anyone, and even for me
the ultimate usefulness is probably quite limited. This post is a testimony
of how I can sometimes spend several hours figuring out interesting
relations between numbers, irregardless of how important it is for my final
application.
Well, I wanted to approximate a circle arc with a number of straight line
segments. I needed the circle arc to have a variable angle but a constant
length, like you have a long object you can bend. Actually it is to become a
bendable bone in a skeletal system I'm working on. It could be used for a
spinal cord or similar.
Now, it'll be practical to have only one type of bones in my system, so I
wanted to simulate this bendable "circle arc" bone using a number of
straight bones after each other.
I set up these criteria:
* The total length of the line segments must equal the length of the circle
arc.
* Individual line segments may not change length during bending (change of
angle).
* The first and last line segment must "touch" (be a tangent to) the circle
arc at the start and end of the circle arc.
* All the angles between the line segments must be the same.
* The first and last line segment may have a different length than the other
line segments.
Now, this problem is a bit tricky. The only way to meet the first four
criteria is to indeed have the first and last line segment be shorter than
the rest. But how much shorter exactly? 50%? More? Less?
The problem is that this varies with both angle and number of segments. So
for a given number of segments and a given angle I need to find the optimal
ratio between middle segment length and end segment length. I made a
POV-script that found this optimal ratio using binary searching.
It turned out that the optimal ratio varies very little with angle (less
than one degree), as long as the angle is smaller than about 135 degrees.
Very lucky, since I couldn't have fulfilled all criteria otherwise!
It changes a lot with the number of segments though. For 3 segments (2
joints) the first and last segment should be 0.25 times the length of the
other segments. For 3 joints the ratio is 0.33, for 4 joints it's 0.38. For
10 joints it's 0.45 and for 50 joints it's 0.49.
Analyzing this a bit it seems like the ratio is 0.5-(0.5/joints).
Interesting eh?
So now I can simulate a circle arc bone using any number of straight bones
with optimal accuracy. I'm sure it'll help me make *much* more realistic
spinal cord movements! And it only took me a few hours to figure out... ;)
Rune
Post a reply to this message
|
|