<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>3D Rendering by BruceDaShark42</title>
		<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42</link>
		<description>Posts in the discussion thread &quot;3D Rendering by BruceDaShark42&quot; - New user BruceDaShark42 would like assistance in optimizing his 3D rendering engine</description>
				<copyright></copyright>
		<lastBuildDate>Sat, 14 Mar 2026 19:13:30 +0000</lastBuildDate>
		
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-8740090#post-4065306</guid>
				<title>Re: 3D Rendering by BruceDaShark42</title>
				<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42#post-4065306</link>
				<description></description>
				<pubDate>Thu, 22 Nov 2018 17:14:17 +0000</pubDate>
				<wikidot:authorName>Shlayne</wikidot:authorName>				<wikidot:authorUserId>4890073</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I went ahead and changed the calculation of matrices [H], [I], and [J] to a single matrix as follows:</p> <div class="code"> <pre><code>: cos(θ→P : sin(θ→Q : -Ans→R : [[P^2+QR^2,PR,PR+PR^2][PQ+PQR,P^2,QR+RP^2][PQ,Q,P^2→[F]</code></pre></div> <p>I've tested it and it seems to work fine, but I wouldn't mind if someone double checked my math just to make sure.</p> <p>For the second part of your post, I didn't actually know matrix multiplication was associative, so that's a big help, thanks! Also, I tried [B](1,1)/C→[D](A,1) and [B](2,1)/C→[D](A,2) and it made the cube pretty much point-like on the screen. But, when I multiplied [B](1,1) and [B](2,1) by C, it was the normal cube again.</p> <p>Edit:<br /> To test out some complex number usage, I changed:</p> <div class="code"> <pre><code>: 1/(L-[B](3,1 : [[Ans,0,0][0,Ans,0 : 20Ans[B]→[B] : [B](1,1→[D](A,1 : [B](2,1→[D](A,2</code></pre></div> <p>To:</p> <div class="code"> <pre><code>: 20/(L-[B](3,1 : Ans[B](1,1)+iAns(2,1→⸤C(A</code></pre></div> <p>And changed the drawing part to:</p> <div class="code"> <pre><code>: For(A,1,4 : For(B,0,4,4 : ⸤C(A+B-(A=4→V : real(Ans→N : imag(V→O : ⸤C(A+B+1+(A=2)-4(A=A→V : real(Ans→S : imag(V : Line(N,O,S,Ans,BLACK,1 : End : ⸤C(A→V : real(Ans→N : imag(V→O : ⸤C(A+4→V : real(Ans→S : imag(V : Line(N,O,S,Ans,BLACK,1 : End</code></pre></div> <p>But, when I tested it out, it appears to have made it slightly slower, and I'm guessing that's because of the imag( and real(, but I'm not too sure.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-8740090#post-4065007</guid>
				<title>Re: 3D Rendering by BruceDaShark42</title>
				<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42#post-4065007</link>
				<description></description>
				<pubDate>Thu, 22 Nov 2018 07:36:51 +0000</pubDate>
				<wikidot:authorName>lirtosiast</wikidot:authorName>				<wikidot:authorUserId>2005367</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Yes, but I mean multiply all the matrices together. In the loop you multiply [B] on the left by [J], then [I], then [H]. But matrix multiplication is associative, so you can compute [H][I][J]→[F] outside the loop and compute [F][B] inside the loop.</p> <div class="code"> <pre><code>1/(L-[B](3,1 [[Ans,0,0][0,Ans,0 20Ans[B]→[B] [B](1,1→[D](A,1 [B](2,1→[D](A,2</code></pre></div> <p>This matrix multiplication is also unnecessary as it just turns a 3x1 matrix into a 2x1 matrix with the values multiplied by C. Just store 20/(L-[B](3,1→C and do [B](1,1)/C→[D](A,1 and [B](2,1)/C→[D](A,2.</p> <p>On a higher level, matrix multiplication is pretty inefficient. I think eliminating all matrices and using complex numbers could bring an improvement, but converting would be nontrivial.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-8740090#post-4064766</guid>
				<title>Re: 3D Rendering by BruceDaShark42</title>
				<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42#post-4064766</link>
				<description></description>
				<pubDate>Wed, 21 Nov 2018 22:30:41 +0000</pubDate>
				<wikidot:authorName>Shlayne</wikidot:authorName>				<wikidot:authorUserId>4890073</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>So instead of:</p> <div class="code"> <pre><code>: [[cos(θ),-sin(θ),0][sin(θ),cos(θ),0][0,0,1→[J] : [[1,0,0][0,cos(θ),-sin(θ)][0,sin(θ),cos(θ→[I] : [[cos(θ),0,-sin(θ)][0,1,0][sin(θ),0,cos(θ→[H]</code></pre></div> <p>It could be:</p> <div class="code"> <pre><code>: cos(θ→P : sin(θ→Q : -Ans→R : [[P,R,0][Q,P,0][0,0,1→[J] : [[1,0,0][0,P,R][0,Q,P→[I] : [[P,0,R][0,1,0][Q,0,P→[H]</code></pre></div> <p>While I was at it, I changed the following:</p> <div class="code"> <pre><code>: [D](A+B-(A=4),1→N : [D](A+B-(A=4),2→O : [D](A+B+1+(A=2)-4(A=4),1→S : [D](A+B+1+(A=2)-4(A=4),2→T</code></pre></div> <p>To:</p> <div class="code"> <pre><code>: A+B-(A=4→V : [D](Ans,1→N : [D](V,2→O : A+B+1+(A=2)-4(A=4→V : [D](Ans,1→S : [D](V,2→T</code></pre></div> <p>Both of which save on bytes and run time.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-8740090#post-4064615</guid>
				<title>Re: 3D Rendering by BruceDaShark42</title>
				<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42#post-4064615</link>
				<description></description>
				<pubDate>Wed, 21 Nov 2018 17:39:45 +0000</pubDate>
				<wikidot:authorName>lirtosiast</wikidot:authorName>				<wikidot:authorUserId>2005367</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>In fact, you can store cos theta and sin theta to variables (since they take 5-10&#160;ms each), then compute [H][I][J], and just multiply that by [B] each time.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-8740090#post-4063359</guid>
				<title>Re: 3D Rendering by BruceDaShark42</title>
				<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42#post-4063359</link>
				<description></description>
				<pubDate>Tue, 20 Nov 2018 08:02:42 +0000</pubDate>
				<wikidot:authorName>Shlayne</wikidot:authorName>				<wikidot:authorUserId>4890073</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Some background info:<br /> This program simulates a cube that rotates in all three planes (x, y, z) using rotation matrices [I], [H], and [J] respectively. The matrix [[Ans,0,0][0,Ans,0]] (located at line 48 in the calculations section) is a projection matrix used to project the cube's 3D points onto the 2D screen. The variable L is the distance from the cube and is used in the perspective projection calculations.</p> <p>One major thing I want help with is the matrix setup part near the top of the program (it's the part that stores the cube's vertices). Basically I want to say (in code): for any given dimension, make a matrix such that all the spots within itself are a binary representation of coordinates (using positive and negative numbers for 1's and 0's).</p> <p>Ex:<br /> dimension = 2<br /> matrix = [[1,1][1,-1][-1,1][-1,-1]]</p> <p>dimension = 3<br /> matrix = [[1,1,1][1,1,-1][1,-1,1][1,-1,-1][-1,1,1][-1,1,-1][-1,-1,1][-1,-1,-1]]<br /> etc.</p> <p>Another idea to refactor this program to make it run faster is to not use matrices at all, but instead, use the math within them and variables A-Z (and θ) to calculate the rotated point's positions.</p> <p>Edit #1:<br /> Eventually, I want to expand the drawing capabilities to draw things other than just cubes, so the idea directly above this to use variables instead of matrices would be kind of moot. Plus, I'd also need a way to store edges, probably with lists or something like that. Not to mention that the drawing edges section would need to be redone completely to accommodate for that.</p> <p>Edit #2:<br /> I just realized I can put the calculations for matrices [H], [I], and [J] right before the for loop on line 38, so it's not calculating them for each point when they're the same for every point.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-8740090#post-4063308</guid>
				<title>3D Rendering by BruceDaShark42</title>
				<link>http://tibasicdev.wikidot.com/forum/t-8740090/3d-rendering-by-brucedashark42#post-4063308</link>
				<description></description>
				<pubDate>Tue, 20 Nov 2018 06:12:32 +0000</pubDate>
				<wikidot:authorName>kg583</wikidot:authorName>				<wikidot:authorUserId>2203149</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>NOTE: The following post and code are taken directly from <span class="error-inline"><em>BruceDaShark42</em> does not match any existing user name</span>, who seeks to optimize and improve his 3D rendering engine for the CE. This post was originally located on its own wiki page, which is NOT advised as procedure in the future. Please ask for assistance on the forums directly. We are happy to help!</p> <hr /> <p>Hey! I just created an account to ask for some optimizations for my 3D rendering program for a TI-84 Plus CE. I've been coding in TI-BASIC for quite some time, so I have sufficient knowledge of the language. This code was translated from <a href="https://youtu.be/p4Iz0XJY-Qk">The Coding Train</a> (java) to BASIC, so the original code is not mine, all I did was port it over.</p> <p>Feel free to drop by and contribute what you may, all help is accepted, including constructive criticism.</p> <p>Here's my code:</p> <div class="code"> <pre><code>: //Setup : ClrHome : TextColor(BLACK : 2→L : : //Matrix Setup : {8,2→dim([D] : {8,3→dim([A] : Fill(.5,[A] : For(A,2,8,2 : -.5→[A](A,3 : End : For(B,0,4,4 : For(A,3,4 : -.5→[A](A+B,2 : End : End : For(A,5,8 : -.5→[A](A,1 : End : : //Graph Setup : 16.5→Xmax : -Ans→Xmin : 10.25→Ymax : -Ans→Ymin : ClrDraw : GridOff : AxesOff : PlotsOff : FnOff : : //Main Loop : 0→θ : Repeat getKey=45 : //Calcualations : startTmr→W : For(A,1,8 : Matr▶list([A]^^T^^,A,L₁ //&quot;^^T^^&quot; is the superscript transpose token : List▶matr(L₁,[B] : [[cos(θ),-sin(θ),0][sin(θ),cos(θ),0][0,0,1→[J] : [[1,0,0][0,cos(θ),-sin(θ)][0,sin(θ),cos(θ→[I] : [[cos(θ),0,-sin(θ)][0,1,0][sin(θ),0,cos(θ→[H] : [J][B] : [I]Ans : [H]Ans→[B] : 1/(L-[B](3,1 : [[Ans,0,0][0,Ans,0 : 20Ans[B]→[B] : [B](1,1→[D](A,1 : [B](2,1→[D](A,2 : End : : //Drawing Edges : ClrDraw : For(A,1,4 : For(B,0,4,4 : [D](A+B-(A=4),1→N : [D](A+B-(A=4),2→O : [D](A+B+1+(A=2)-4(A=4),1→S : [D](A+B+1+(A=2)-4(A=4),2→T : Line(N,O,S,T,BLACK,1 : End : [D](A,1→N : [D](A,2→O : [D](A+4,1→S : [D](A+4,2→T : Line(N,O,S,T,BLACK,1 : End : : Text(0,0,&quot;SPF: &quot;,checkTmr(W //SPF is seconds per frame : θ+π/16→θ : End</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>