.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Space Empires: IV & V (http://forum.shrapnelgames.com/forumdisplay.php?f=20)
-   -   OT - math question. (http://forum.shrapnelgames.com/showthread.php?t=11372)

narf poit chez BOOM February 19th, 2004 08:11 AM

OT - math question.
 
say you had a point at the bottom of a sphere and then moved it to the right a random distance along the surface of the sphere. how would you calculate the height from the bottom?

[ February 19, 2004, 06:11: Message edited by: narf poit chez BOOM ]

Fyron February 19th, 2004 08:21 AM

Re: OT - math question.
 
Calculate the degrees away from the pure vertical radius that the new radial line connecting to the new point on both the x and y planes. Then use some arc length calculations.

narf poit chez BOOM February 19th, 2004 08:23 AM

Re: OT - math question.
 
that's the problem. i know neither the y position nor the arc calculations.

Fyron February 19th, 2004 08:44 AM

Re: OT - math question.
 
Umm... if you are moving it in a random direction, should you not be able to see where it is moving to?

Either way, measure the vector between the start point and the end point. You can get the angles from this vector with pythagorian theorm used a few times. If you have coordinates, no measurement is required, just calculations.

Member 4148 February 19th, 2004 08:51 AM

Re: OT - math question.
 
Quote:

Originally posted by narf poit chez BOOM:
say you had a point at the bottom of a sphere and then moved it to the right a random distance along the surface of the sphere. how would you calculate the height from the bottom?
<font size="2" face="sans-serif, arial, verdana">if it is traveling in a straight line, it might as well be on the edge of a circle, as you are starting from the ultimate "south" position (nowhere to go but north)

you need your distance traveled - call that d
you need the radius of the sphere - call that r

now, set your graphin calculater into radian mode
then tell it to do the following equation

height from bottom = (sin((d/r) - pi/2) * r) + r

there are lots o variation on this equation

drop the +r to get the height above (+) or below (-) th center

Member 4148 February 19th, 2004 08:53 AM

Re: OT - math question.
 
Quote:

Originally posted by Imperator Fyron:
Umm... if you are moving it in a random direction, should you not be able to see where it is moving to?

Either way, measure the vector between the start point and the end point. You can get the angles from this vector with pythagorian theorm used a few times. If you have coordinates, no measurement is required, just calculations.

<font size="2" face="sans-serif, arial, verdana">i think he is looking for y position - he has starting point, path traveled (along surface of sphere), distance traveled, wants ending point

Fyron February 19th, 2004 09:00 AM

Re: OT - math question.
 
y position is not height. Not sure what I was thinking with arc length, but you definitely need the angles associated with the vector from the starting point to the ending point. The relative height is just the z component of that vector.

Treating the movement as along a circle only works if the only component that is changing is the z component. If x or y change (but not both), then it is no longer a circle, but an ellipse.

narf poit chez BOOM February 19th, 2004 09:01 AM

Re: OT - math question.
 
yes, thank you, will try the calculation.

Fyron February 19th, 2004 09:04 AM

Re: OT - math question.
 
Actually... if you have the arc length, that gives you the angles you need to calculate the height, as you can calculate the percent of the 360 degress of the circle that that arc takes up using the 2 * pi * radius calculation for circumference.

narf poit chez BOOM February 19th, 2004 09:12 AM

Re: OT - math question.
 
no, that part wasn't stated well. i don't have the arc length, only the x distance moved.

Member 4148 February 19th, 2004 09:21 AM

Re: OT - math question.
 
Quote:

Originally posted by Imperator Fyron:
y position is not height.
<font size="2" face="sans-serif, arial, verdana">can be - it depends on coordinate system used
there is no particular reason why the center of the sphere has to be the 0 point - he wanted the answer from the bottom of the sphere after all
likewise there is no particular reason why z has to be up, y back, and x right - reducing to circle makes y up using cartesian so it works as height
Quote:

Originally posted by Imperator Fyron:
Not sure what I was thinking with arc length, but you definitely need the angles associated with the vector from the starting point to the ending point. The relative height is just the z component of that vector.

Treating the movement as along a circle only works if the only component that is changing is the z component. If x or y change (but not both), then it is no longer a circle, but an ellipse.

<font size="2" face="sans-serif, arial, verdana">you forgetting - he constraining himself to move on surface of sphere - any 'straight line' path constrained so makes for a segment of a perfect circle from some perspective - if you choose that perspective, it reduces to a circle just fine
also, narf specified direction of travel - to the right - which pretty much forces a circle sgement anyway

narf poit chez BOOM February 19th, 2004 09:54 AM

Re: OT - math question.
 
x is left/right, y is up/down, z is not used.

it's a random straight line x movement and i need the y position on the sphere that a line straight up would hit.

sorry for not being clear the first time. i guess i need to reread mathamatical Posts at least three times.

Member 4148 February 19th, 2004 10:03 AM

Re: OT - math question.
 
Quote:

Originally posted by narf poit chez BOOM:
x is left/right, y is up/down, z is not used.

it's a random straight line x movement and i need the y position on the sphere that a line straight up would hit.

sorry for not being clear the first time. i guess i need to reread mathamatical Posts at least three times.

<font size="2" face="sans-serif, arial, verdana">Oh. That's easier -
need: r: radius of sphere
d: distance traveled
want: h: height above bottom edge of sphere

edit: small mistake on co-ordinate system - fixed
h = r - sqrt(r - d^2)

notes:
not defined for |d| > r
above applies for lower edge
upper edge is h = r + sqrt(r - d^2)

[ February 19, 2004, 08:08: Message edited by: Member 4148 ]

narf poit chez BOOM February 19th, 2004 10:39 AM

Re: OT - math question.
 
and if your wondering what you worked so hard on http://forum.shrapnelgames.com/images/icons/icon10.gif , think big bowling ball. no, bigger than that. http://forum.shrapnelgames.com/images/icons/icon10.gif

thanks, guys.

'coincedently', there's a new hazard in my game. http://forum.shrapnelgames.com/images/icons/icon10.gif

Cipher7071 February 19th, 2004 05:37 PM

Re: OT - math question.
 
Attack of the killer bowling balls...
Run for your lives!!!
....aaaarrrrrrrrrggggh....splat ! http://forum.shrapnelgames.com/images/icons/icon10.gif


Incidentally, if the distance traveled is very small compared to the size of the ball, then you can probably make do with an approximation. In that case, the pythagorean theorum or the tangent function will probably do the trick.

Fyron February 19th, 2004 06:09 PM

Re: OT - math question.
 
Quote:

Originally posted by Member 4148:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">quote:</font><hr /><font size="2" face="sans-serif, arial, verdana">Originally posted by Imperator Fyron:
y position is not height.

<font size="2" face="sans-serif, arial, verdana">can be - it depends on coordinate system used
there is no particular reason why the center of the sphere has to be the 0 point - he wanted the answer from the bottom of the sphere after all
likewise there is no particular reason why z has to be up, y back, and x right - reducing to circle makes y up using cartesian so it works as height
</font><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">No, it doesn't have to be, but it does certainly help if you either stick to a standard coordinate system or define the one you are working in. http://forum.shrapnelgames.com/images/icons/icon7.gif

narf poit chez BOOM February 19th, 2004 09:05 PM

Re: OT - math question.
 
it's not the distance traveled - they're so big they flatten things. http://forum.shrapnelgames.com/images/icons/icon10.gif


All times are GMT -4. The time now is 02:09 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.