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.

Author
Message
Behdadsoft
17
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 17th May 2013 18:47
Hi.

Can someone clearly explain this script to me?



THANKS
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 17th May 2013 19:05
Newzvalue and newxvalue calculates a new Z or X value for you. For instance Newzvalue(Current Z value,The Y angle in which direction you want the new value, The amount of points in that direction you want to calculate)

It takes the current Z value and turns in the Y direction you define and calculates it in that direction for as many units you specify. Do you understand my bad explanation?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Behdadsoft
17
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 17th May 2013 20:57 Edited at: 17th May 2013 21:52
Quote: "
Do you understand my bad explanation?
"


Thanks for explanation, Not Sorry I don't understand.I need explanation for Newzvalue and Number 100 In parentheses. and I want know Why subtracted 180 degrees from the aY# Value?
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 17th May 2013 21:56 Edited at: 17th May 2013 22:00
The first parameter is the current z co-ordinate, the second parameter is the angle of the movement, and the third parameter is the number of units to move. The underlying code for this command is along the lines of 'NewZ = OldZ + Cos(Angle) * Distance'.

With an angle of 0 the movement would be straight forward, so the result of 'NewZValue(0, 0, 1)' would be the original z value, 0, moved forward by 1 unit. Which gives us 1.

With an angle of 90 the movement would be entirely sideways, along the x axis, so the z co-ordinate would be unaffected. Therefore the result of 'NewZValue(0, 90, 1)' would be the original z value, 0, unaffected.

With an angle of 45 the movement would be a diagonal. Using trigonometry, we can work out that the ratio the z co-ordinate would be affected by movement at this angle to be about 0.7. Therefore, the result of 'NewZValue(0, 45, 1)' would be the original z value, 0, moved by the distance, 1, multiplied by the ratio, 0.7. Which gives us 0.7.

The 'NewXValue' is the same but for the x co-ordinate, and hence uses the underlying code 'NewX = OldX + Sin(Angle) * Distance'.

I hope that makes some sense but please let me know if you need anything explained more clearly.

[Edit] I had to make some punctuation and grammar tweaks. [/Edit]


Previously TEH_CODERER.
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 18th May 2013 10:34 Edited at: 18th May 2013 10:35
It is a displacement calculation based on a current x#,z# position and angle in the form of :

newx#=newxvalue(currentx#,angle#,displacement)
newz#=newzvalue(currentz#,angle#,displacement)

it can be used to displace some object relative to another moving or rotating object

it can be used for calculating the next position for moving around by recalculating on the current position, angle, and speed as displacement value:

x#=newxvalue(x#,angle#,speed#)
z#=newzvalue(z#,angle#,speed#)

it can be used to keep the camera behind a moving object putting a negative displacement

attached examples
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 18th May 2013 10:35
following
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th May 2013 13:02
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)

Translation:

cZ# = Z# + cos(aY#-180)*100
cX# = X# + sin(aY#-180)*100

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Behdadsoft
17
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 20th May 2013 09:57
Thanks All

Login to post a reply

Server time is: 2026-07-06 18:36:40
Your offset time is: 2026-07-06 18:36:40