Just a thought, the wikipedia article on 3D projection has the formulae and matrices for projection of a 3d object onto a 2d screen. By the way, Matrices are probably the best way to track 3d points.

From what I've heard, 3d projection in pure ti-basic is pretty slow. Nonetheless, it would be cool to give it a try using that wikipedia page. But I currently can't think of how to translate the stuff on that page to ti-basic…

Also, here's one of the pages I found a while back: "Plotting 3D Points onto a 2D screen"

Just created this, using the first example (orthographic) from the page you linked. It doesn't allow you to move the camera at all, but it does project 3d points, in pure ti-basic. You can adjust window dimensions if you want any of your 3d points to be negative.

```
ClrHome
0->Xmin:1->DeltaX
0->Ymin:1->DeltaY
AxesOff
ClrDraw
3->dim(L1
[[0][0->[A]
Input "ScaleFctrX=",D
Input "ScaleFctrZ=",E
Input "OffsetX=",F
Input "OffsetZ=",G
Input "Iterations:",Z
Line(F,G,F,G+5 //y axis
Line(F,G,F+5,G //x axis
[[D,0,0][0,0,E]][[4][0][4]]+[[\F][\G
Line(F,G,Ans(1,1),Ans(2,1 //z axis
For(A,1,Z
For(B,1,3
Input sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1)+sub("xyz",B,1)+"=",C //the limit of points you can have is 26 before it errors out
C->L1(B
End
[[D,0,0][0,0,E]][[L1(1)][L1(2)][L1(3)]]+[[\F][\G //formula from wikipedia
If A>1
Line([A](1,1),[A](2,1),Ans(1,1),Ans(2,1
Pt-On(Ans(1,1),Ans(2,1
Ans->[A]
End
```

Btw, don't worry about the [\F] and [\G] things, those are just the variables F and G inside a matrix (not the matrices F and G). The backslash tells the source coder IDE i use to not use the usual matrix token.

Thoughts?

Currently it draws lines between your previous point and the one you just entered, so it's not very customizable. You could change it easily though, and you could also just remove the line() part at the end to just give you points.

```
For(A,1,Z
For(B,1,3
Input sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1)+sub("xyz",B,1)+"=",C
```

That part is pretty clever

basically

`[[D,0,0][0,0,E]][[L1(1)][L1(2)][L1(3)]]+[[\F][\G`

takes the point (x,y,z), gets rid y to get (x,z) then multiplies by a scale factor D and E, then add a constant F and G.

(X,Y,Z) -> (DX+F,EZ+G)

you can easily make this into a perspective drawing with the help of similar triangles

(X, Y, Z) -> (DX/Y+F, EZ/Y+G)

in matrix form

[[D/Y, 0, 0][0, 0, E/Y]] x [[X][Y][Z]] + [[F][G]]

Keep in mind that this puts the camera at (0,0,0) all points behind the camera are inverted using this method (it's all good as long as everything is in front of the camera). You can move the camera by moving all the points away from the camera

With 3D drawing, its not about moving the camera around the object, its more like moving the object around the camera.

Thanks :) the only problem I can see there is that if the user enters in 0 for Y, it errors out…

Also, do I have to change window settings, or something? I entered in my x y and z, and then I increased the z without increasing anything else, but the point only moved up (2d) from the previous point…

another problem is that entering a value higher than 1 for y makes it go farther towards the bottom left corner (or ~0,~0 in 2d and what seems to be ~0,~0,~0 in 3d)

I believe I may just look on the wikipedia page and try to figure it out myself, but if you could help me with this that'd be cool :D

Yes, that is because parallel lines in perspective tend to converge to a single point, a vanishing point, you see this in real life and in perspective drawings.

Because the camera is at 0,0,0 and is pointing parallel with the y axis, that puts the vanishing point at (0,0) on the screen. To move the vanishing point you have to change your window settings or change the OffsetX and OffsetZ.

I thought I was on to something, but now I'm getting frustrated…

can't get it to work the way I want it to. Tried making a cube with 8 pts, but only ended up with 4 points that look like a plane, facing the camera. for this test I turned off the axes and disabled line-drawing (only pts).

or maybe I just don't understand fully. I think I'll try the perspective thing from the wikipedia page now, but it will probably be more confusing than this… :/

Good point with that program about the lists, they can store 3 dim points as opposed to matrices. I'm glad my suggestion could go so far. Perhaps this could be developed further?

Working on it. This is actually my first time stepping into 3d programming, so it's pretty exciting :D

Of course, this would probably be way better if it wasn't TI-Basic, but sadly I don't know the other calculator languages :(

If I can interpret the wikipedia page well enough, which I'm sure I can eventually, I may be able to make a program where you can rotate the camera around.

Btw, I am working on BasicNote as well, so I am not able to work on this full-fledged yet. It's not really good to have multiple projects going at once…

Yeah 3D is pretty confusing at first, but once you start to understand you realize its really simple.

For those who havent seen it, this is a 3D engine I made in TI-Basic.Its using maths based on some stuff I learned in MV calculus to project points in 3D which seems easier to understand, for me.

It being an engine, and not a stand alone program, it can use any input method for drawing, directly imputing points, generating points based on an equation (as shown above), or maybe even a 3D game in the future.

Basically you input the point the camera is at, the point the camera is looking at, the zoom and the focal length. Then it calculate the projection plane, and a representation of the screen in 3D.

To convert points, it creates a line from that point to the camera, finds the intersection of that line and the projection plane, then finds the projection of that point to each axis of the screen to get x and y.

Most the math is done with dot product and cross product of vectors

The program is capable of orthographic and perspective projection, orthographic being almost twice as fast, from (almost) any camera position, angle, zoom and focal length.

But now that I understand, I'm making a new program based on the wikipedia page, I suspect the results to be much faster.

very nice. I have seen that gif before, but I'm still a bit amazed how you got it to do that. Looking forward to your new program :)

I thought you posted the code for that somewhere, but I forgot. Maybe you didn't, but if you did perhaps you could link it?

Yeah, no rush. I tried drawing a cube with it so far, but its kind of hard to. I think Perspective projection would be best, and You should enter the points at first, Tell it what points to connect with lines, then it draws it.

This could be useful for vector projection. Especially if you were able to rotate it

-live the life because the life is good -vivir la vida, porque la vida es buena

-Vie la vie que la vie est bonne -quod est bonum vitae in vita

-lebe das Leben, weil das Leben ist gut -vivere la vita, perché la vita è buona

Okay, before I start my attempt at the perspective projection, I need some help… and sorry if the wikipedia page says this, I just need it in simpler terms…

before I start applying the math, I need to know what θ_{x,y,z} and e_{x,y,z} could be. If someone could show an example that'd be great. I just need to understand those variables better. Like, would the theta be degrees 0-180 or 360 or something or what? and e i don't even know where to start… I'm clueless, and the page doesn't explain it in the simplest way.

Think of your head as the camera at the origin.

Turn your head x degrees (look left and right) aka pan

Turn your head y degrees (look up and down) aka tilt

Turn your head z degrees (like you're confused about something) aka roll

e aint that important

If you look into why it works, instead of just copying the equations, it will make a lot more sense.

Research transformation matrices.

Okay, thanks. What could I put in for e_{x,y,z} though? It says on the page that to compute the 2d coords, you need this formula, which includes e:

1 for ez and ex and ey are the x and y offset

Not the most optimized code, but it's what I could come up with in a short time period.

```
ClrHome
AxesOff
ClrDraw
~23.5->Xmin:23.5->Xmax
~15.5->Ymin:15.5->Ymax
0->D //camera is at 0,0,0 (i used only 1 var since all 3 pts are the same)
0->dim(L2 //converted 3d data (x and y)
{~3,~3,~3,~3,~3,3,3,~3,3,3,~3,~3,~3,3,~3,~3,3,3,3,3,3,3,3,~3->L1 //x,y,z,x,y,z etc (these 8 pts should make a cube)
~45->A:~45->B:0->C //orientation (a=x, b=y, c=z)
1->E:0->F:0->G //Ez,Ex,and Ey
For(Z,1,dim(L1),3
[[1,0,0][0,cos(~A),~sin(~A)][0,sin(~A),cos(~A)]][[cos(~B),0,sin(~B)][0,1,0][~sin(~B),0,cos(~B)]][[cos(~C),~sin(~C),0][sin(~C),cos(~C),0][0,0,1]]([[L1(Z)][L1(Z+1)][L1(Z+2)]]-[[\D][\D][\D]])->[A] //formula on wikipedia
(E/Ans(3,1))Ans(1,1)-F->L2(1+dim(L2
(E/[A](3,1))[A](2,1)-G->L2(1+dim(L2
End
For(Z,1,dim(L2),2
Pt-On(L2(Z),L2(Z+1
End
```

so, I thought this would make a cube, but obviously something went wrong. I only see 4 pts instead of 8, but this time they actually look kind of 3d. of course, i'm never going to get anything perfect on my first try, but… anyways, here's a pic:

Points behind the camera are inverted, you're trying to look at the whole cube from inside the cube, which can produce very strange results (but sometimes kinda cool). Move the camera farther back (or the cube farther away) and see what happens.

heh. well something else is wrong then. the most top right corner should be at (3,3,3), but even when the camera is outside of that it gets weird…

CAMERA AT:

(5,5,5):

(9,9,9):

(15,15,15):

Another helpful website for rotations:

wikpedia rotation matrix