OK, cool.

And I find no frustrum clipping sort of annoying, don't know about others though.
flyingfisch wrote:
OK, cool.

And I find no frustrum clipping sort of annoying, don't know about others though.
I implemented a lame sort of frustrum culling/clipping; it just culls every line with an endpoint behind the eye plane rather than calculating the actual frustrum volume and clipping at the edges of the frustrum. Works well enough, including for your 1.5^X example. I also implemented the [EXIT] key from all the menus as requested.
KermMartian wrote:
flyingfisch wrote:
OK, cool.

And I find no frustrum clipping sort of annoying, don't know about others though.
I implemented a lame sort of frustrum culling/clipping; it just culls every line with an endpoint behind the eye plane rather than calculating the actual frustrum volume and clipping at the edges of the frustrum. Works well enough, including for your 1.5^X example. I also implemented the [EXIT] key from all the menus as requested.


Nice Smile

So it looks about ready for release?
Yup, looks just about ready. I haven't seen any solid suggestions or comments on Omnimaga, I'll wait to see what Ashbad has to say about it, and pending another other comments while I'm packing it up and preparing a video, 1.0 is ready.
I'm sorry (and glad) to say that while I had suggestions and problems, they have all been mentioned and fixed already; awesome work Kerm. I won't be using it for math classes this year, but I'm sure many others will be!
Ashbad wrote:
I'm sorry (and glad) to say that while I had suggestions and problems, they have all been mentioned and fixed already; awesome work Kerm. I won't be using it for math classes this year, but I'm sure many others will be!
Many thanks! That's about all that I needed to hear, so I'm going to start packing this up for its 1.0 release now.
Hey, I found one more little problem! Very Happy

In trace mode, the bounding box is drawn over the trace numbers. It should be drawn below.

Great job! Smile
RC2 is great. The bugs seem to be gone, and it's easier to use Smile

One quick last-minute suggestion: having a sample equation in the Z= editor on first use. DS's Graph3 uses Z=(X3YY3X)/390.
Thanks for both of those last-minute suggestions, both of which I have implemented. The video is published, the file is about to head into the archives, and the news article will be a short write!
That's strange... My graph screen is now pale red/pale green instead of black/white. I assumed it was a new feature to lower the contrast until I saw the video D:
Deep Thought wrote:
That's strange... My graph screen is now pale red/pale green instead of black/white. I assumed it was a new feature to lower the contrast until I saw the video D:
Err? Please try with the latest version and let me know what happens. The issue might be that you were using the old state save file; try deleting @MainMem/@Graph3DP/G3DP.
Yeah, that was it. Thanks!
Deep Thought wrote:
Yeah, that was it. Thanks!
Neat-o. This happened when you switched from Release Candidate 1 to 2, correct? If so, I can rest easy; otherwise, I'll worry that this is going to pop up again?
Yes, that's all.
I have a suggestion to make. With generic 3d code it is easy to render stereo pair of a 3d plot. On a computer it does not make sense since screen is far away, but with a calculator it might work.

Anyway, I made several stereo images (on a PC) and sized them to 384x216 to view on Prizm with imgviewer to give a preview what it would feel like.



And here is some quick and dirty lua code to rotate a cube in stereo.
Just as an illustration of a concept.
arrows=rotate cube
+/- = farther/closer (affects perspective)
*// = larger/smaller (does not affect perspective)
sin/cos = chnage eye base
exe = switch left and right (for cross-eye vs parallel eye)

I think it has its potential. For tricky 3d surfaces or illustrations of stereometric theorems.


Code:

-- Rotate 3d object in stereo
-- (C) nsg, 2013

function mat_mul(m1,m2)
  -- resulting matrix has as many rows as m1 and as many columns as m2
  local res={}
  for r=1,#m1 do
    local row={}
    assert(#m1[r]==#m2)
    -- print("mul r=",r)
    for c=1,#m2[1] do
      local s=0
      for k=1,#m2 do
        s=s+m1[r][k]*m2[k][c]
      end
      table.insert(row,s)
    end
    table.insert(res,row)
  end
  return res
end

function mat_transpose(mat)
  local res={}
  for i=1,#mat[1] do
    table.insert(res,{})
  end
  for r=1,#mat do
    for c=1,#mat[r] do
      table.insert(res[c],mat[r][c])
    end
  end
  return res
end

function mat_make_rotation(axis,angle)
  local mat={}
  for r=1,3 do
    table.insert(mat,{})
    for c=1,3 do
      local v=0
      if r==axis and c== axis then v=1
      else v=0
      end
      table.insert(mat[r],v)
    end
  end
  local c=math.cos(angle)
  local s=math.sin(angle)
  mat[(axis+0)%3+1][(axis+0)%3+1]=c
  mat[(axis+0)%3+1][(axis+1)%3+1]=s
  mat[(axis+1)%3+1][(axis+0)%3+1]=-s
  mat[(axis+1)%3+1][(axis+1)%3+1]=c
  return mat
end


function make_cube(side)
  if nil==side then
    side=1
  end
  local function coord(i,mask)
    return (0==bit32.band(i,mask) and side or -side)
  end
  local vertex={}
  local edge={}
  for i=0,7 do
    table.insert(vertex,{coord(i,1),coord(i,2),coord(i,4)})
    local bit=1
    for b=1,3 do
      local next=bit32.bxor(i,bit)
      if next<i then table.insert(edge,{i+1,next+1}) end
      bit=bit*2
    end
  end
  return vertex,edge
end

function mat_dump(m,name)
  if nil==name then name="?" end
  print(string.format("matrix %s with %d rows",name,#m))
  for r=1,#m do
    io.write(string.format("%3d:",r))
    for c=1,#m[r] do
      io.write(string.format(" %3d",m[r][c]))
    end
    io.write("\n")
  end
end

function dumpargs(...)
  print(...)
end

function nothing() end

if nil==zmg then
  zmg={
    makeColor=function() return 999 end,
    drawLine=dumpargs,
    keyMenu=function()
      io.write("key=");
      local k=io.read();
      return tonumber(k)
    end,
    drawRectFill=dumpargs,
    fastCopy=dumpargs,
  }
else
  mat_dump=nothing
end

m,e=make_cube(10)


mat_dump(m,"vertexes")
mat_dump(e,"edges")

SCREENX,SCREENY=384,216
BLACK=zmg.makeColor(0,0,0)
xrot=5.585
yrot=0.436
SCL=265
AWAY=57
OX=SCREENX/2
OY=SCREENY/2

function screenfrom3d(v)
    local z=SCL/(v[3]+AWAY)
    return OX+v[1]*z, OY+v[2]*z
end

function V_drawbody(v,e)
  for i=1,#e do
    local x1,y1=screenfrom3d(v[e[i][1]])
    local x2,y2=screenfrom3d(v[e[i][2]])
    zmg.drawLine(x1,y1,x2,y2,clr)
  end
end

function V_display()
  local rot=mat_transpose(mat_mul(mat_make_rotation(1,xrot),mat_make_rotation(2,yrot)))
  mat_dump(rot,"rot")
  mat_dump(m,"m")
  local v=mat_mul(m,rot)
  mat_dump(v,"translated vertexes")

  clr=zmg.makeColor(255,255,255)
  zmg.drawRectFill(0,0,SCREENX,SCREENY,BLACK)

  local vt=mat_mul(v,EYE1)
  OX=(flip and 3 or 1)*SCREENX/4
  V_drawbody(vt,e)
 
  vt=mat_mul(v,EYE2)
  OX=(flip and 1 or 3)*SCREENX/4
  V_drawbody(vt,e)

  zmg.fastCopy()
end

PI2=math.pi*2
dx=5*PI2/360
dy=dx
flip=false

function makeeyes(eyebase)
  EYEBASE=eyebase
  EYE1=mat_make_rotation(2,eyebase)
  EYE2=mat_make_rotation(2,-eyebase)
end

makeeyes(4*PI2/360)

K_EXIT=  47
K_LEFT=  38
K_DOWN=  37
K_UP=    28
K_RIGHT= 27
K_SIN=   46
K_COS=   36

K_DEL=   44 -- [DEL]   
K_MUL=   43 -- [*] 
K_PLUS=  42 -- [+] 
K_NEG=   41 -- [(-)]
K_DIV=   33 -- [/] 
K_MINUS= 32 -- [-] 
K_EXE=   31 -- [EXE]

function playstereo()
  quit=false
  repeat
    V_display()
    local k=zmg.keyMenu()
    if k==K_EXIT then quit=true
    elseif k==K_LEFT  then yrot=yrot+dy
    elseif k==K_RIGHT then yrot=yrot-dy
    elseif k==K_UP    then xrot=xrot-dx
    elseif k==K_DOWN  then xrot=xrot+dx
    elseif k==K_PLUS  then AWAY=AWAY-1
    elseif k==K_MINUS then AWAY=AWAY+1
    elseif k==K_MUL   then SCL=SCL*1.1
    elseif k==K_DIV   then SCL=SCL/1.1
    elseif k==K_SIN   then makeeyes(EYEBASE-0.001)
    elseif k==K_COS   then makeeyes(EYEBASE+0.001)
    elseif k==K_EXE   then flip=not flip
    end
    xrot=xrot % PI2
    yrot=yrot % PI2
  until quit
  print("yrot=",yrot)
  print("xrot=",xrot)
  print("AWAY=",AWAY)
  print("SCL=",SCL)
  print("EYEBASE=",EYEBASE)
  print("flip=",flip)
end

A=playstereo -- to easy typing in prizm

playstereo()


nsg wrote:
I have a suggestion to make. With generic 3d code it is easy to render stereo pair of a 3d plot. On a computer it does not make sense since screen is far away, but with a calculator it might work.

Anyway, I made several stereo images (on a PC) and sized them to 384x216 to view on Prizm with imgviewer to give a preview what it would feel like.





If I ever have a bunch of money and time to waste, I would get a 3D monitor and glasses kit and make gCAS3 have support for 3D stereo graphing. Also, making these image to make me go cross-eye was a nice touch Very Happy
on a similar note, an option to set polyfill would be cool. Wink
ok... I have found a bug now that i am actually using this for math.

First, when tracing Z1=X, when X=1, Z=-.999..., when X=2, Z=-1.999...

This is obviously incorrect.

Also, maybe it is too late, but what about having it calculate the points on the graph once, store it to an array, and then display the 3d array the same way you would with any 3d model? Wouldn't this allow faster spinning?
flyingfisch wrote:
ok... I have found a bug now that i am actually using this for math.

First, when tracing Z1=X, when X=1, Z=-.999..., when X=2, Z=-1.999...

This is obviously incorrect.
That's an artifact of the floating-point format. I (and by "I" I mean "vprintf") should probably be rounding instead of truncating.

Quote:
Also, maybe it is too late, but what about having it calculate the points on the graph once, store it to an array, and then display the 3d array the same way you would with any 3d model? Wouldn't this allow faster spinning?
That's what it already does. The computations it needs to do during rotation are the transformations for scale and rotation.
  
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
Page 4 of 5
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement