Register

Stereo

Topics on released projects. Only the author of a program should start a topic on it.
Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Stereo

Postby nsg » Tue Feb 19, 2013 2:21 am

I made a Basic program for Prizm that generates stereo images of wireframe 3d objects.
I posted it to download section.
http://www.casiopeia.net/forum/downloads.php?view=detail&df_id=91

To speed up calculations it uses matrix operations -- which turn out to be surprisingly fast.
Unfortunately, Prizm's glacial graphics speed more than makes up for that.
Couple of sample 3d objects for viewing are supplied with the zip.

Image

Please, post here if you encounter problems.
If you make some 3d objects to view, I would love to see them too.

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: Stereo

Postby Casimo » Tue Feb 19, 2013 4:01 pm

Could you share the source as txt file so I can port it to the fx9860 / can you port it?
I want to learn from it.
Image

Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Re: Stereo

Postby nsg » Tue Feb 19, 2013 6:39 pm

I included .txt file in the dispribution .zip

Below is a copy of it with some comments.

It should work pretty much the same, I do not use any special features except color in one place.
But I am afraid that at low resolution pixels will be too large and will interfere with depth perception effect.
Could you please post picture of what it looks like in low res?

Code: Select all
'ProgramMode:RUN
'
'Save coordinates in Nx3 matrix V '
List->Mat(3,4,5)->Mat V
' Initialize rotation matrices '
' X is a matrix that rotates around x axis '
' Y -- y axis '
' R -- total rotation, accumulated during the session '
' 10 degrees = rotation step, both for X and Y '
10deg->Theta
Identity 3->Mat X
Mat X->Mat Y
Mat X->Mat R
Mat X->Mat E
cos Theta
Ans->Mat X[2,2
Ans->Mat X[3,3
Ans->Mat Y[1,1
Ans->Mat Y[3,3
sin Theta
Ans->Mat X[2,3
Ans->Mat Y[1,3
(-)Ans->Mat X[3,2
(-)Ans->Mat Y[3,1
' E is "eye rotation" matrix. This is how much '
' each eye deviates from a central line '
3deg->Theta
cos Theta
Ans->Mat E[1,1
Ans->Mat E[3,3
sin Theta
Ans->Mat E[1,3
(-)Ans->Mat E[3,1
' '
' '
' View window setup '
GridOff
AxesOff
' We choose to run y from -0.11 to 0.11 '
' with all coordinates inside unit sphere and '
' viewing distance of 10 that would be about '
' right size to fit all coordinates into the view '
0.11->Ymax
(-)Ymax->Ymin
' 63/31 is a screen ration on Prizm which keeps x scale same as y scale '
Ymax*63frac31->Xmax
(-)Xmax->Xmin
' '
' Main loop '
Do
Cls
' do twice, once for each eye '
For (-)0.5->B To 0.5
' calculate coordinates as original coordinates times '
' accumulated roatation matrix plus left or right eye rotation adjustment '
' E has the property that E^-1=Trn(E), so we use Trn instead of ^-1 as more '
' efficient '
If B<0
Then Mat V*(Mat R*Trn Mat E
Else Mat V*(Mat R*Mat E
IfEnd
' 3 colulmn is Z coordinate '
' Move everything away 10 units. '
' This is empiricaly selected value to make perspective distortions '
' large enough, but not too large. '
10+Mat->List(Mat Ans,3
' Adjust X coordinates for perspective distortions (Z) and shift '
' left or right depending on the eye '
(Mat->List(Mat Ans,1)/List Ans)+BXmax->List 6
' Adjust Y coordinates for perspective distortions. '
Mat->List(Mat Ans,2)/List Ans->List 7
' '
' Draw the lines '
' This is the biggest time hog. '
For 1->A To Dim List 1
' Color commad is a possible source of incompatibility with older models '
Blue SketchThin F-Line List 6[List 1[A]],List 7[List 1[A]],List 6[List 2[A]],List 7[List 2[A]]
' check for key inside the loop to update rotation without need to wait '
Getkey->K
K<>0=>Goto 2
Next
Next
Do:Getkey:LpWhile 0=Ans:Ans->K
Lbl 2
' Update matrix R (which holds accumulated rotation) '
' depending on key press. '
' Again, special properties of matrices X and Y allow use of Trn in place of ^-1 '
K=28=>Mat R*Mat X->Mat R
K=37=>Mat R*Trn Mat X->Mat R
K=27=>Mat R*Mat Y->Mat R
K=38=>Mat R*Trn Mat Y->Mat R
While Getkey:WhileEnd
LpWhile K<>47
' Cleanup all, except, possibly R which holds accumulated transformation. '
ClrList6
ClrList7
ClrMat V
ClrMat X
ClrMat Y
ClrMat E
'_ClrMat _R '

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: Stereo

Postby Casimo » Wed Feb 20, 2013 8:19 pm

I can't port it; the fx9860-basic doesn't have 3d-mats.
Are you planning to make ths in c, too?
Image

Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Re: Stereo

Postby nsg » Wed Feb 20, 2013 8:35 pm

What do you mean by "3d mats"? I do not use any 3d mats.

As far as different languages, I first made it in LuaZM (it is posted on Cemetech in LuaZM section), it could be easily ported to other Luas.

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: Stereo

Postby Casimo » Thu Feb 21, 2013 6:36 am

Your Mat V has got 3 dimensions, doesn't it?
Image

Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Re: Stereo

Postby nsg » Thu Feb 21, 2013 2:24 pm

No, it is a usual 2 dimensional matrix.
Contains vertex corrdinates. Three columns, and as many rows as there are vertexes.
It even says it right there in the comment: "Nx3"

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: Stereo

Postby Casimo » Thu Feb 21, 2013 3:25 pm

The thing is that on the fx9860 you can't write
Code: Select all
List->Mat(3,4,5)->Mat V

So could you explain what happens here?

The only thing I know is that you store something in Mat V :D
Image

Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Re: Stereo

Postby nsg » Thu Feb 21, 2013 4:39 pm

List->Mat( is a function that converts lists to column matrix. With several arguments converts several lists into that many column matrix.
"List->Mat(3,4,5) -> Mat V" takes lists 3, 4 and 5 and makes them columns of matrix V.

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: Stereo

Postby Casimo » Thu Feb 21, 2013 5:08 pm

Oh, i thought that would be more than one command :) I'll try it again.
Image

Next

Return to Released Projects

Who is online

Users browsing this forum: No registered users and 20 guests