This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
Basjuh


Advanced Newbie


Joined: 19 Nov 2003
Posts: 56

Posted: 20 Nov 2003 05:19:41 pm    Post subject:

Does anybody know the exact calculations for displaying a 3d object on the screen... i have already the sqrt(x,y,z) but that only gives the distance from the 0,0,0 point and i still need the angle of that line...
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 20 Nov 2003 05:28:10 pm    Post subject:

Do you mean points only?

Generally:

X = (256 * (X / (Z + zCenter)) + xCenter)
Y = (256 * (Y / (Z + zCenter)) + yCenter)

This will give you the correct position as well as perspective ... but u might have to play around with the zCenter and the 256 a little.

Still it wont be fast in basic.


Last edited by Guest on 21 Nov 2003 01:34:46 am; edited 1 time in total
Back to top
Basjuh


Advanced Newbie


Joined: 19 Nov 2003
Posts: 56

Posted: 20 Nov 2003 05:37:19 pm    Post subject:

yes points only.

what value have zCenter,yCenter and xCenter? thats the 0,0,0 point right?

i know it wont be fast but i just use it for testing, making it faster and maybe using it for somthing...


Last edited by Guest on 20 Nov 2003 05:39:23 pm; edited 1 time in total
Back to top
Basjuh


Advanced Newbie


Joined: 19 Nov 2003
Posts: 56

Posted: 20 Nov 2003 05:59:45 pm    Post subject:

and why 256 you'll get really big values that way....
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 21 Nov 2003 01:32:11 am    Post subject:

xCenter, and yCenter are used because the native 0,0 part of the screen is the top left corner. Adding these two will make 0,0 in the middle of the screen.

xCenter = ScreenWidth / 2 ... so its just (96 / 2)
yCenter = ScreenHeight / 2 ... so its just (64 / 2)
zCenter = How far away from the screen you want the center point to be ... play with this value, 128 or 256 work pretty good.

As far as the 256 at the start goes ... well 128 might be a better alternative. Lets plug in some values.

say u have x = 10, y = 10, z = 10. Now:

X = (128 * (X / (Z + zCenter)) + xCenter)
Y = (128 * (Y / (Z + zCenter)) + yCenter)

therefore:

X = (128 * (10 / (10 + 256)) + 4Cool
Y = (128 * (10 /( 10 + 256)) + 32)

You MUST convert to integer .. with 'int()'.

X_Pos = 53
Y_Pos = 37

So you would draw your point at (53,37). That seems fine to me (as the 0,0 is really at the center of the screen ... so the points 'really' convert to (5,5)).

Just play around with the values to see what looks right.


Last edited by Guest on 21 Nov 2003 01:33:25 am; edited 1 time in total
Back to top
Basjuh


Advanced Newbie


Joined: 19 Nov 2003
Posts: 56

Posted: 21 Nov 2003 06:17:28 am    Post subject:

Great you're the man it works perfectly.... Smile Very Happy
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 21 Nov 2003 12:25:09 pm    Post subject:

Hey no problem Very Happy .... do you want to know about rotations and stuff?
Back to top
Basjuh


Advanced Newbie


Joined: 19 Nov 2003
Posts: 56

Posted: 21 Nov 2003 08:52:26 pm    Post subject:

if you can tell me ok, i know its some calculation with sinus and cosinus, but i dont know it anymore
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 23 Nov 2003 09:18:52 am    Post subject:

Ok Rotations :)

Around the X-Axis:

X = X
Y = Y * Cos(Pitch) - Z * Sin(Pitch)
Z = Y * Sin(Pitch) + Z * Cos(Pitch)

Around the Y-Axis:

X = Z * Sin(Yaw) + xT * Cos(Yaw)
Y = Y
Z = Z * Cos(Yaw) - xT * Sin(Yaw)

And About the Z-Axis:

X = Y * Sin(Roll) + X * Cos(Roll)
Y = Y * Cos(Roll) - X * Sin(Roll)
Z = Z

Ok Pitch, Yaw & Roll are all angles of rotation. These work well with really small values (like 0.1). Dont forget to convert with int() before displaying Wink.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 23 Nov 2003 02:01:42 pm    Post subject:

tr1p1ea wrote:
Dont forget to convert with int() before displaying Wink.

IF using Pxl-On(, Pt-On( should work fine without using Int(, but then you have to make sure you have the window set up.


Last edited by Guest on 23 Nov 2003 02:02:12 pm; edited 1 time in total
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 24 Nov 2003 03:25:26 pm    Post subject:

tr1p1ea wrote:
Ok Rotations :)

[manifold equations snipped]

Would it be better to use discrete values or matrices?
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 25 Nov 2003 09:35:29 am    Post subject:

Well applying a rotation matrix would be a good idea, however i wanted to show what exactly is going on. Plus im hardly an expert in the subject Very Happy.
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 16 Dec 2003 08:09:59 pm    Post subject:

Kinda off topic....are there any BASIC game programs that have successfully simulated a decent 3-D environment? I downloaded resident evil and it was horrible (graphics, movement, shooting etc).
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement