Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Equation of Circle in 3D space

Author
Message
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 11th Oct 2005 04:11
I have found this equation using google for an ellipse in 3D. However I have no idea how to use it... I ran some numbers through theta (t) and did get it to plot a circle in 3D space, but I could not figure out how to manipulate it's rotation around each axis.

x(t) = Cx + a cos(t) Ux + b sin(t) Vx
y(t) = Cy + a cos(t) Uy + b sin(t) Vy
z(t) = Cz + a cos(t) Uz + b sin(t) Vz

I am trying to write some code that can generate the points on a circle in 3D space. I want to be able to manipulate the circle by radius, rotation around center point x, rotation around center point y, and rotation around center point z. When done I want to place a 3D Plane through the circle.

Thanks!
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 11th Oct 2005 07:37 Edited at: 11th Oct 2005 07:40
theta is a letter from the greek alphabet, which is used as a standard varable in Math as an angle, so, 't' is the angle or rotation

I really don't understand your equations
what are Vx and Cx? and what is a?

maybe i'm just an idiot... haha, yeah i am

No one, not even your grandmother, loves their toaster as much as Young Rob does
My BLOG really sucks...
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 11th Oct 2005 10:14 Edited at: 11th Oct 2005 10:33
umm! [edit]...nope! that didn`t work, not a clue.





£350 worth of books later and I still can`t make any sense of C++, BASIC forever
kevil
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 11th Oct 2005 11:44
Basically (Cx, Cy, Cz) is the center of the ellipse and (Ux, Uy, Uz) and (Vx, Vy, Vz) are the two axes of the circle. And a en b are the ellipse scale factors. So, to rotate such an ellipse, you'll have to rotate the axes.

Kevil
Tommy S
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location:
Posted: 11th Oct 2005 12:40
wierd that this crops up just as i'm having a similar problem. It seems my maths ain't what it used to be. I want to work the equation the other way round. I have the radius and centres of two circles (just in 2d for now). I know they intersect and i want to find the point of intersection. I know asking people to do this for me is frowned upon but if anyone who knows a lot more maths than me could post the equation i would be much obliged.
Nul error
19
Years of Service
User Offline
Joined: 12th Aug 2005
Location:
Posted: 11th Oct 2005 15:21
Nice this prob fits in to my hardpoint problem I posted in the newbies thread but only responce I got was lazy man ways.
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 11th Oct 2005 16:02
Thanks Kevil, I believe you are correct cause I have seen things mentioning that. However, I have not been successful in finding how one goes about doing that. Would you mind giving a demonstration on how you would do that? Can we do an example? Lets say I want a circle with a radius of 50 and the circle will be rotated by 45 degrees on all 3 axis.
Mika
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 13th Oct 2005 02:45
Hi alls,

I had some time to spent on your matter and this is an example example I just completed to write that can be a start of solution. Of course this example program is not perfect and must be enhanced to support the functions you need but I think it will bring you some usefull information in order to manage your circle rotation in 3D space.

Mike
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 13th Oct 2005 15:35
Thank you Mike! I was beginning to lose heart on this whole issue. I had been reading that vectors were the way to go when translating axis -- but I have had no experience with them. I'm guessing I should get a book on it.

I will try this code out tonight when I get home, and whether it works or not, I apreciate your direction, sample, and time!
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 14th Oct 2005 02:11
Hey Mike! That equation has gotten me the closest I have ever been to completing this problem. I was wondering if you could look at my sample and see where I am messing up. The sample is supposed to spin a circle randomly. When it stops spinning it is supposed to attatch a sphere at a random location on the circle (or orbit). It gets really close but there is still some kind of miscalculation going on.

Attachments

Login to view attachments
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 14th Oct 2005 10:09
I don't get the equation.



I just can't make an ordinary circle with it. It's always an ellipse...

Immunity and Annihalation makes Immunihalation...
Mika
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 14th Oct 2005 17:34
Hi,

Ninja, I just had few minutes to test your application.
As I understand it you want to sinchronize a planet with its orbit represented by your colorfull ring, and the matter is that the planet is not well attached to its orbit in some circumstances. Am I correct ?

SVen B, please could you update you post with the list of the function keys to use in your application and explain what you want to perform ? Moreover, you do not need the equation on Z#, as a circle is basically a 2D figure.
So the correct equation is :
x(a) = center x + radius x * cos(a)
y(a) = center y + radius y * sin(a).

Mike
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 14th Oct 2005 17:50
Howdy Mike,

Yes. You are correct. I am trying to synchronize a planet with it's orbit represented by the ring. The ring's look and feel is just a place holder for the moment. I will be replacing it with a better looking DirectX object later.

In about 40% of the cases the planet is not attaching to the orbit. But your equations are getting it very close if not on the orbit the other 60% of the time. I am wondering if it has something to do with the with the scaling of the orbit plain versus the radius of the ring. The ring is only a plain with a texture applied to it.

Also, just as an aside.. I realize that some of the code in the demo I sent is hackish -- in fact a few if not one of the functions is being passed something it doesn't even use. I was gonna clean it up after I got it working. I also want to redo the code that spins the orbit so it is a little more graceful.
Mika
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 15th Oct 2005 02:39
Ninja,

One thing you can do is the following. It will certainly modify your code design orientation but, as I can imagine it would work (not tested on my side):

- Store your orbit in a table of vectors.
- Attach your 3D object to one vector of this table (let says the first).
- Loop
-- Perform orbit transformation.
-- Perfomr 3D object transformation in the same way.
-- Attach your 3D object to the next vector of the table (i.e. set the 3D object x,y and z to the vector values).
- Loop

Following this way to do, you will certainly have some interesting results. I can imagine also that this orientation have some issues (e.g. to store the whole orbit coordinates in a table --> the more you will want to be precise, the more you table will be large).

Mike
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Oct 2005 13:18 Edited at: 15th Oct 2005 13:27
Mika,

I have written the keys before the data. (q - a) means you have to use q to decrease and a to increase.

Everyone. For the people that want to know how to calculate an orbit:



No vectors. Pure math, and a lot of trigometry...
(Man I'm happy. I tried this 7 times before and it finally works)

Cheerz everyone

Sven B

Immunity and Annihalation makes Immunihalation...
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Oct 2005 13:36
Wow. Useful codes there. Thanks, that should come in handy if my EZRotate ever breaks

Mika
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 15th Oct 2005 20:24
All,

Nice code from Sven B, I believe it could be very useful for Ninja ant its matter of orbit synchronisation.

It should be interesting to transform the orbit by rotation matrix and let it turn around the planet. To be tested.

Mike
Mika
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 17th Oct 2005 01:28
Hi,

In attachement new and updated functions to manipulate matrices. The example is based on the same strategy that the 1st one I had provided in this thread.
However, now a I just completed to implement a list of functions in order to manipulate matrices (addition, multiplication, rotation, translation and scale). Other subject related function is also provided.

The matrices manipulation functions are based on memblocks usage, and I would like to ask some people to test those functions in order to see if they are enough stable (e.g. monkey testing and so on ...) to be put on the code data base. Many thanks for your returns.

I believe also that those functions can be greatly enhanced by the usage of 3D Math DB pro proprietary API that is unfortunately not really well documented. I would try to re-implement my functions with this API in order to benefit from speed improvement. To b studied.

Mike

Attachments

Login to view attachments
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 17th Oct 2005 05:23
Wow! Very impressive code Mika. You have put a lot of thought and effort into that.

I am trying to digest all the information presented here and will post a finished solution to my problem when I figure it out. (or additional questions) heheheheh
Ninja
22
Years of Service
User Offline
Joined: 15th Oct 2002
Location:
Posted: 17th Oct 2005 05:31
Great job too Sven! Both of these demonstrations have lots of good information in them.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Oct 2005 10:10
Thx!

Mika,
Great code. Though I doubt if I could use it in a program because it's a litle slow . (20fps)
Still, I think it's a great piece of coding you wrote there...

Immunity and Annihalation makes Immunihalation...
Mika
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 17th Oct 2005 14:17
Thanks everybody.

For speed matter, I believe you can augment FPS ratio by passing only the desired vector to the transformation matrix process. I based my example on the same strategy than for the 1st implementation and all the vectors stored are sent to transformation matrix process before a display synchronisation (i.e. that means 360 calls to _applyTranformationMatrixTo3DVector() which contains a lot of tests in order to secure the function and 16 product operations are needed for each vector).

Moreover, as I said previously, I believe that the function speed could be greatly enhanced by the use of 3D math api of DB Pro that provide vector and matrix supports. Unfortunately this API is very poorly documented, meaning that its use is not really easy.

One thing interresting to do is to use my matrice functions on your example Sven B and let rotate your orbit around your planet.
I believe that in this case FPS should be better. Won't you try it ?

Mike
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Oct 2005 15:00
Go ahead...

I'm not very familiar with matrices/vectors in DBP. A little new for me(I just come from DBC and bought DBP)

Immunity and Annihalation makes Immunihalation...
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 18th Oct 2005 00:21
Go off and read my vector guide then. Do a search on the forums to find it. Kentaree is cheerfully hosting it. Although, he seems to have broken most of the links (boo, hiss).

Cheer if you like bears! Cheer if you like jam sandwiches!
P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
Mnemonix
22
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 18th Oct 2005 04:03
With your approval, I can host the vector tutorial for you if Kentaree can no longer do so.

WE SHALL BECOME ALL POWERFUL! CRUSH THE LESSER RACES! CONQUER THE GALAXY! UNIMAGINABLE POWER! UNLIMITED RICE PUDDING ! ! ! ETC. ! ! ! ETC.! ! !

Login to post a reply

Server time is: 2025-06-01 10:04:18
Your offset time is: 2025-06-01 10:04:18