Making a pentagon face a 3D origin (Mathstuff)

Registered User regular
I want to start out saying that this is not a homework problem. It's a personal project I'm working on but need a bit of help on the math bit as I am very weak and haven't been in high school for over 25 years.

I'm making a celestial globe and I'm trying to map out the stars.
Now lots of the heavy math I've done myself. I downloaded a cool star catalog from Yale that had the stars in Right Ascension by Degrees. Using excel, I was able to convert that into X,Y, and Z coordinates by doing some polar conversion math I found online. I now have a celestial sphere, and can put a point on it where a star is located, but now It's a little more tricky

At each point of X,Y, and Z; I need to create a pentagon (even better an N-gon) of radius r using.... someway and then have the normal face the center of the sphere at 0,0,0. (Basically, at the sphere center, you should see the pentagon flat looking out)

In a nutshell a function to take an point of X,Y,Z, and Radius, and spit out 5 X,Y,Z vertices representing the points of the pentagon.

For the record, I have a basic idea how to do algebra, and I haven't seen trig in many, many moons. So, my math-fu is weak.

Posts

• San DiegoRegistered User regular
There won't be just one regular polygon facing the origin given an x, y, z with a radius -- it can still be rotated around the normal vector. That said, you could certainly get an equation to give you the point of a polygon that fits the criteria.

This may be pretty difficult to do if you don't have trig. But I think the steps are:

1. Calculate the normal vector from the origin to the center point
2. Calculate the equation for the circle on the plane perpendicular to that normal vector, using the center point
3. The vertices of the polygon you want will touch that circle. Put one vertex at 0 degrees, then calculate the other points of the polygon -- divide 360° by the number of vertices/sides to get the needed angles and then plug those into the circle equation

The equations for the normal vector and the circle may be hard to understand with basic algebra and trig, though.

• Registered User regular
I knew That I would have to do something with the normal vector and a matrix transform... I was hoping there was a slick sin/cos tomfoolery that would get me to bypass it. I'm doing this in blender (in python) so I may be able to leverage some of blender's facilities, It's just Processing 9,110 stars as objects may be a little heavy for my machine. (I was hoping to cheat and just use vertices). It starts to chug after ~2500 empty objects are created.

The steps are helpful though... I'll play with it tonight.

• Registered User regular
Might it not be easier (mathematically) to create the ngon at the location with a default orientation, then rotate it to match the vector?

(Assuming the api you're using has an object rotation function.)

• Registered User regular
edited January 2017
I cheated. I just put a sphere at the location and it looks like a circle from any direction you look at it

However I do have a little easier basic math I'm figuring out now.
(1 * n = 0.010)
(2 * n = ?)
(3 * n = ?)
(4 * n = 0.005)
(5 * n = ?)
(6 * n = ?)
(7 * n = 0.001)


Taking the values on the left, you can preform a calculation get the value on the right. I think it's a multiplier of some sort but I don't know how to derive what n should be. I tried looking up who to do this is Google, but I don't even know the name of this kind of a progression.

The idea is a feed a floating point number from 1 to 7 and it will spit out a number from 0.010 to 0.001 proportionally.

I know this is probably basic math stuff, and I can solve for n in each case, but not ... continually as a function(?)

halkun on

• Registered User regular
edited January 2017
((n-1)/6 * 0.009) + 0.001

ArbitraryDescriptor on
• Registered User regular
edited January 2017
a Max output is 0.01
b Minimum output is 0.001
x Max input is 7
y Minumum input is 1

((n-y)/(x-y) * (a-b)) + b

So a-b is the range, and the position within it as a percentage is (n-y)/(x-y). Then you add the start point b.

ArbitraryDescriptor on
• Registered User regular
edited January 2017
Thanks for the Mathstuff. Here's a link of with it helped accomplish..

http://imgur.com/a/dYSkP

The first is Orion, with icospheres different radii based on the magnitude
and the second is the globe showing 2500 of the 9100 stars (Anything Magnitude 5.3 and above.. I may go up to 6, but I think the sky may get too cluttered, and my system starts to chug after 4000 stars)

halkun on

• Registered User regular
halkun wrote: »
Thanks for the Mathstuff. Here's a link of with it helped accomplish..

http://imgur.com/a/dYSkP

The first is Orion, with icospheres different radii based on the magnitude
and the second is the globe showing 2500 of the 9100 stars (Anything Magnitude 5.3 and above.. I may go up to 6, but I think the sky may get too cluttered, and my system starts to chug after 4000 stars)

That performance seems strangely low. Are you just building the scene via script and viewing this in Blender? Some game engine?

• Registered User regular
edited January 2017
Building with a script. The problem is that each icosphere is being created as it's own object with all the baggage that comes with it. Once they are generated I can merge them into one object (after about 4 min of churning) and it behaves normally.

Keep in mind I'm also on a Core 2 Duo with 4 GB of ram.. I'm a little underpowered

halkun on

• Registered User regular
Would your original n-gon solution be better? I don't think the math would be that hard. Like the first step, the vector that is normal to your desired polygon is simply the coordinates where you want the face to be.

• Registered User regular
edited January 2017
I played with it last night. As I have the original X,Y map of the stars I could rotate a n-gon by the amount it was defected from 0,0 - but I gave up and just used the icospheres instead. It's not that big of a deal, as I have to project parts of the sphere onto a flat plane so I can add constellation art textures and then project the textured sphere to globe gores anyway. I can work with 1/12 of an orange slice at a time.

I guess if it isn't really obvious, I'm making a physical celestial globe, the star map is just one of the "layers" I'll be adding to the final sphere texture. I'm using Blender to help with the projection.

halkun on

• Registered User regular
I don't think you need matricies at all. Just calc vector from star to origin and you have your normal + point, that defines a plane. Then you just place your points on the plane and voila. I can provide the formulae in about 12 hours

In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
• Registered User regular
Naa, I'm good. I was able to import what I needed. I just let the system churn for a half hour and I got all the stars down to magnitude 6.

I now have a globe with stars, coordinate lines, and borders. The math you were able to provide helped a lot!

Picture below:
https://blenderartists.org/forum/attachment.php?attachmentid=469945&d=1485751197