Omnimaga

Calculator Community => Other Calculators => Topic started by: bfr on October 12, 2006, 10:08:00 am

Title: 3-D Cube Rotating
Post by: bfr on October 12, 2006, 10:08:00 am
If you thought the 3-D environment was cool, I made a program that lets the user rotate a 3-D cube vertically and horizontally, all in pure TI-BASIC (which required a lot of mathematics).  B)cool.gif

Here's a screenshot of it running on a regular TI-83+ (and note that it is unoptimized):

user posted image

I'll try to get a download link up soon.

Title: 3-D Cube Rotating
Post by: DJ Omnimaga on October 13, 2006, 12:57:00 am
hmm i wonder if this could be used in a isometric game with rotating map/camera? not in basic tho but prbly in C
Title: 3-D Cube Rotating
Post by: CureDesu on October 14, 2006, 02:08:00 am
 O_Oshocked2.gif That must have taken a LOT of math knowledge.
Title: 3-D Cube Rotating
Post by: bfr on October 14, 2006, 02:30:00 am
Yeah, it involved quite a bit of mathematics.    
Title: 3-D Cube Rotating
Post by: DJ Omnimaga on October 14, 2006, 02:36:00 am
could you post the formula/code?
Title: 3-D Cube Rotating
Post by: bfr on October 14, 2006, 03:33:00 am
Here is the source code that SourceCoder genereated (and remeber, it's unoptimized):

QuoteBegin-"Basic Code"+-->
QUOTE ("Basic Code")
::
:1→Xmin
:95→Xmax
:1→Ymin
:63→YMax
:Radian
:40,40,60,40,60,20,40,20,40,40,60,40,60,20,40,20→L1
:(√(800)π)→A
:(7/8)A,A/8,A/8,A/8,A/8,(7/8)A,(7/8)A,(7/8)A,(5/8)A,(3/8)A,(3/8)A,(3/8)A,(3/8)A,(5/8)A,(5/8)A,(5/8)A→L2
:(2π)/(π√(800))→R
:√(800)/2→Q
:Lbl R
:ClrDraw
:iPart(Q(sin(RL2))+40→L1
:For(A,1,5,2
:Line(L1(A),L1(A+1),L1(A+2),L1(A+3)
:End
:Line(L1(7),L1(8),L1(1),L1(2)
:For(A,9,13,2
:Line(L1(A),L1(A+1),L1(A+2),L1(A+3)
:End
:Line(L1(15),L1(16),L1(9),L1(10)
:For(A,1,7,2
:Line(L1(A),L1(A+1),L1(A+8),L1(A+9)
:End
:Repeat G
:getKey→G
:End
:If G=26
:Then
:For(A,1,15,2
:L2(A)+1→L2(A)
:End
:End
:If G=24
:Then
:For(A,1,15,2
:L2(A)-1→L2(A)
:End
:End
:If G=25
:Then
:For(A,2,16,2
:L2(A)+1→L2(A)
:End
:End
:If G=34
:Then
:For(A,2,16,2
:L2(A)-1→L2(A)
:End
:End
:Goto R
Generated by http://www.cemetech.net/projects/basicelite/sourcecoder.php,
Title: 3-D Cube Rotating
Post by: DJ Omnimaga on October 14, 2006, 03:35:00 am
it just ask me to open a file o.oblink.gif
Title: 3-D Cube Rotating
Post by: bfr on October 14, 2006, 03:39:00 am
I fixed my post :)smile.gif
Title: 3-D Cube Rotating
Post by: DJ Omnimaga on October 14, 2006, 03:47:00 am
square roots and all *gasp* x.x hopefully maybe one day I'll get the hang of it O_Oshocked2.gif

sound cool tho  
Title: 3-D Cube Rotating
Post by: bfr on October 14, 2006, 05:22:00 am
Yeah.  There's this one line of code that is really important, and determines the coordinates of the points in terms of radian angles:

c1-->
CODE
ec1:iPart(Q(sin(RL2))+40→L1c2
ec2
Title: 3-D Cube Rotating
Post by: DJ Omnimaga on October 14, 2006, 05:26:00 am
hmm I c, I should try to study some 3d stuff a bit more in case i decided to do some 3d prog in the future on PC or if I ever learned a language faster than TI-BASIC
Title: 3-D Cube Rotating
Post by: Radical Pi on October 14, 2006, 08:36:00 am
Basic can get so complicated...

I'm not impressed by the video or that it constantly redraws, but the mere fact that you did it in Basic is lolzomgwtfzorsinmypants. And like you said, it can probably get alot faster.
Good job.
Title: 3-D Cube Rotating
Post by: JincS on October 14, 2006, 11:15:00 am
Looks pretty cool! Kudos.

I have a n00b question: I know when programming in C/C++, you can write screen data to a buffer before you send it to the screen, which increases frame rate and reduces flicker. Is there a way to do that in BASIC?
Title: 3-D Cube Rotating
Post by: DJ Omnimaga on October 14, 2006, 11:21:00 am
in pure basic, no. WIth xLIB commands you can choose to send it immediately or just save it to graph buffer. It's cool cuz then I ended up being able to make a DDR clone with animated background with arrows moving up