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 / 3D tubular movement

Author
Message
Braude Interactive
19
Years of Service
User Offline
Joined: 1st Aug 2006
Location: Sheffield, UK
Posted: 21st Oct 2011 18:12
I'm trying to align some smaller cylinders around the outside of a larger cylinder.

I had it working for x and z co-ordinates, but I can't work out what to do with the y co-ordinate.

I'd done it by finding a position on the radius of the larger cylinder at the top of the cylinder (using sin and cos) and working out how much I had to move the origin of the small cylinders by (using newxvalue etc) to line the tops up.

However, the smaller cylinders all stayed at the same y coordinate when I changed the declination of the large cylinder. So I am looking at changing my code, from the simple x and z position finder, to something that finds a position on the edge of a sphere, given its radius, an angle of orientation (azimuth)and an angle of declination.
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 22nd Oct 2011 22:11
Hi, Braude Interactive.

By "declination" I'm assuming you mean that you're wanting to pitch, roll and turn the main cylinder and have the "satalite" cylinders remain in position relative to the main cylinder. The demo below is an example of how to do this (actually it's just pitching and turning but you'll get the idea).



I'm not entirely sure this is what you were asking but I hope this helps or at least gives you some inspiration.
Braude Interactive
19
Years of Service
User Offline
Joined: 1st Aug 2006
Location: Sheffield, UK
Posted: 25th Oct 2011 10:18
ah, yeah, that's a nice way of doing it. I don't need to roll the main cylinder, just turn and pitch it. I was trying to do it mathematically, but I was getting knotted up with the trig. Trying to convert from radial locations to absolute cartesian coordiantes. I'll give your method a go.

Thanks 29, I'll let you know how I get on
Braude Interactive
19
Years of Service
User Offline
Joined: 1st Aug 2006
Location: Sheffield, UK
Posted: 25th Oct 2011 10:30
Actually, that's really helped me out. In about 5 minutes work I've got done what had me tearing my hair out last week. Thank you.

Any idea how I can actually calculate the co-ordinates of a point on the circumference of a cylinder though?

I need to run a ray check down the outside of the cylinder, the other objects are more of a visual guide.
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 25th Oct 2011 23:34 Edited at: 25th Oct 2011 23:37
What you can do is use the same principle as the demo I posted and then use the GET OBJECT POSITION commands to get the XYZ coordinates.

Instead of the cylinder, use an invisble marker object. To move the marker object onto the curved surface of the cylinder I would do the following:

1: position and orientate the marker object to the cylinder
2: move the marker object upward or downward as this will move it along the cylineder's axis.
3: turn the marker object to the desired angle.
4: move the marker object forward by the cylinder's radius.
5: write the marker object's XYZ coordinates to variables. This now give you the first point for the ray cast.

Repeat these steps to get the second point. You can use the same marker object, just use different variables. This then gives you the start and end point of the ray cast.

A demo of using a marker object to calculate coordinates can be found in this thread (second post down). It's not doing what you're trying to do but it will give you an idea.

http://forum.thegamecreators.com/?m=forum_view&t=186811&b=1
Of course, if you do go down the maths route, at least this is a way for checking your equations.
Braude Interactive
19
Years of Service
User Offline
Joined: 1st Aug 2006
Location: Sheffield, UK
Posted: 26th Oct 2011 13:08
I did it exactly as you described. Works a dream. Kicking myself for not thinking of this simple approach before! Thank you

Login to post a reply

Server time is: 2026-07-10 09:57:28
Your offset time is: 2026-07-10 09:57:28