how to rotate a quad, math pls


    Sep 25 2007 | 8:42 pm
    I'm looking to rotate a mesh based quad(s). idle with a changeable center of rotation. a patch would be lovely but the expression used or a link to further info would help. much. i wish i could combine mesh based rendering with glrotate... yair

    • Sep 25 2007 | 9:01 pm
      attachment, rotation equation taken from an opengl book
      On 9/25/07, yair reshef wrote: > > I'm looking to rotate a mesh based quad(s). idle with a changeable center > of rotation. a patch would be lovely but the expression used or a link to > further info would help. much. > i wish i could combine mesh based rendering with glrotate... > yair >
    • Sep 25 2007 | 9:29 pm
      Hello, Here are some jit.expr objects that will do x, y, z rotations with an anchor at 0. I had this lying around, so I can't tell you what is what.
      I don't have the time to work it out right now, but you could probably use a vertex shader to rotate the geometry in a much more efficient way by passing in vertex attributes or by using one of the jit.gl.mesh inputs for the rotation amount for each quad and doing the matrix transformation in the vertex program. See the recent thread called "Setting GLSL attribute variables per vertex with Jitter" for more info on using vertex attributes in a shader.
      Best, Andrew B.
      yair reshef wrote: > attachment, rotation equation taken from an opengl book > > On 9/25/07, *yair reshef* > > wrote: > > I'm looking to rotate a mesh based quad(s). idle with a changeable > center of rotation. a patch would be lovely but the expression used > or a link to further info would help. much. > i wish i could combine mesh based rendering with glrotate... > yair > > > > ------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ >
    • Sep 26 2007 | 12:55 am
      On that note, I checked in the 1.6 docs, and did not see anything about vertex attributes.
      Also, this is one thing that GEM does quite quite well, using nested translation and rotation objects to geometry for transforms. 2.0 PLZ? K THNX BAI! :)
      On Sep 25, 2007, at 5:29 PM, andrew benson wrote:
      > Hello, > Here are some jit.expr objects that will do x, y, z rotations with > an anchor at 0. I had this lying around, so I can't tell you what > is what. > > #P window setfont "Sans Serif" 9.; > #P window linecount 2; > #P newex 188 205 310 196617 jit.expr @expr in[0] "in[0].p[1]*cos(in > [1])-in[0].p[2]*sin(in[1])" "in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in > [1])" in[0] in[0]; > #P newex 188 170 290 196617 jit.expr @expr "in[0].p[0]*cos(in[1])+in > [0].p[2]*sin(in[1])" in[0] "in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in > [1])" in[0] in[0]; > #P newex 188 134 297 196617 jit.expr @expr "in[0].p[0]*cos(in[1]) - > in[0].p[1]*sin(in[1])" "in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in > [1])" in[0] in[0] in[0]; > #P connect 1 0 2 0; > #P connect 0 0 1 0; > #P window clipboard copycount 3; > > I don't have the time to work it out right now, but you could > probably use a vertex shader to rotate the geometry in a much more > efficient way by passing in vertex attributes or by using one of > the jit.gl.mesh inputs for the rotation amount for each quad and > doing the matrix transformation in the vertex program. See the > recent thread called "Setting GLSL attribute variables per vertex > with Jitter" for more info on using vertex attributes in a shader. > > Best, > Andrew B. > > > > yair reshef wrote: >> attachment, rotation equation taken from an opengl book >> On 9/25/07, *yair reshef* >> > wrote: >> I'm looking to rotate a mesh based quad(s). idle with a >> changeable >> center of rotation. a patch would be lovely but the expression >> used >> or a link to further info would help. much. >> i wish i could combine mesh based rendering with glrotate... >> yair >> --------------------------------------------------------------------- >> --- >> --------------------------------------------------------------------- >> ---
      v a d e //
      www.vade.info abstrakt.vade.info
    • Sep 26 2007 | 8:12 am
      thanks Andraw. i have no problem as of yet with mesh vertex performances. works great. included is a patch implemnting your math for the internet to store.
      On 9/25/07, vade wrote: > > On that note, I checked in the 1.6 docs, and did not see anything about > vertex attributes. > Also, this is one thing that GEM does quite quite well, using nested > translation and rotation objects to geometry for transforms. 2.0 PLZ? > K THNX BAI! > :) > > On Sep 25, 2007, at 5:29 PM, andrew benson wrote: > > Hello, > Here are some jit.expr objects that will do x, y, z rotations with an > anchor at 0. I had this lying around, so I can't tell you what is what. > > #P window setfont "Sans Serif" 9.; > #P window linecount 2; > #P newex 188 205 310 196617 jit.expr @expr in[0] > "in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])" > "in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])" in[0] in[0]; > #P newex 188 170 290 196617 jit.expr @expr > "in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])" in[0] > "in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])" in[0] in[0]; > #P newex 188 134 297 196617 jit.expr @expr "in[0].p[0]*cos(in[1]) - > in[0].p[1]*sin(in[1])" "in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])" in[0] > in[0] in[0]; > #P connect 1 0 2 0; > #P connect 0 0 1 0; > #P window clipboard copycount 3; > > I don't have the time to work it out right now, but you could probably use > a vertex shader to rotate the geometry in a much more efficient way by > passing in vertex attributes or by using one of the jit.gl.mesh inputs for > the rotation amount for each quad and doing the matrix transformation in the > vertex program. See the recent thread called "Setting GLSL attribute > variables per vertex with Jitter" for more info on using vertex attributes > in a shader. > > Best, > Andrew B. > > > > yair reshef wrote: > > attachment, rotation equation taken from an opengl book > On 9/25/07, *yair reshef* >> > wrote: > I'm looking to rotate a mesh based quad(s). idle with a changeable > center of rotation. a patch would be lovely but the expression used > or a link to further info would help. much. > i wish i could combine mesh based rendering with glrotate... > yair > ------------------------------------------------------------------------ > ------------------------------------------------------------------------ > > > > *v a d e //* > > *www.vade.info* > *abstrakt.vade.info* > > > > > >
    • Sep 26 2007 | 8:14 am
      long live the shatter
      On 9/26/07, yair reshef wrote: > > thanks Andraw. i have no problem as of yet with mesh vertex performances. > works great. included is a patch implemnting your math for the internet to > store. > > > > On 9/25/07, vade wrote: > > > > On that note, I checked in the 1.6 docs, and did not see anything about > > vertex attributes. > > Also, this is one thing that GEM does quite quite well, using nested > > translation and rotation objects to geometry for transforms. 2.0 PLZ? > > K THNX BAI! > > :) > > > > On Sep 25, 2007, at 5:29 PM, andrew benson wrote: > > > > Hello, > > Here are some jit.expr objects that will do x, y, z rotations with an > > anchor at 0. I had this lying around, so I can't tell you what is > > what. > > > > #P window setfont "Sans Serif" 9.; > > #P window linecount 2; > > #P newex 188 205 310 196617 jit.expr @expr in[0] > > "in[0].p[1]*cos(in[1])-in[0].p[2]*sin(in[1])" > > "in[0].p[2]*cos(in[1])+in[0].p[1]*sin(in[1])" in[0] in[0]; > > #P newex 188 170 290 196617 jit.expr @expr > > "in[0].p[0]*cos(in[1])+in[0].p[2]*sin(in[1])" in[0] > > "in[0].p[2]*cos(in[1])-in[0].p[0]*sin(in[1])" in[0] in[0]; > > #P newex 188 134 297 196617 jit.expr @expr "in[0].p[0]*cos(in[1]) - > > in[0].p[1]*sin(in[1])" "in[0].p[1]*cos(in[1]) + in[0].p[0]*sin(in[1])" in[0] > > in[0] in[0]; > > #P connect 1 0 2 0; > > #P connect 0 0 1 0; > > #P window clipboard copycount 3; > > > > I don't have the time to work it out right now, but you could probably > > use a vertex shader to rotate the geometry in a much more efficient way by > > passing in vertex attributes or by using one of the jit.gl.mesh inputs > > for the rotation amount for each quad and doing the matrix transformation in > > the vertex program. See the recent thread called "Setting GLSL > > attribute variables per vertex with Jitter" for more info on using vertex > > attributes in a shader. > > > > Best, > > Andrew B. > > > > > > > > yair reshef wrote: > > > > attachment, rotation equation taken from an opengl book > > On 9/25/07, *yair reshef* >> > > wrote: > > I'm looking to rotate a mesh based quad(s). idle with a changeable > > center of rotation. a patch would be lovely but the expression used > > or a link to further info would help. much. > > i wish i could combine mesh based rendering with glrotate... > > yair > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > > > > > > > > > * v a d e //* > > > > * www.vade.info* > > * abstrakt.vade.info* > > > > > > > > > > > > >
    • Sep 26 2007 | 4:45 pm
      On Sep 25, 2007, at 5:55 PM, vade wrote:
      > On that note, I checked in the 1.6 docs, and did not see anything > about vertex attributes.
      Relatively experimental feature at the time of doc writing. Forum for vertex attr info is best.
      > Also, this is one thing that GEM does quite quite well, using > nested translation and rotation objects to geometry for transforms. > 2.0 PLZ? K THNX BAI!
      These objects are just a bang chain with the gltranslate, glrotate, glscale calls. You can easily simulate this stuff in jit.gl.sketch. If you need a bang chain, just make a few jit.gl.sketch @immediate 1 wrappers and use @automatic 0 for the objects. It's *really* simple if you want to program procedural bang chains like this. It's just not the paradigm we're going to focus our object set on.
      -Joshua
    • Sep 26 2007 | 8:19 pm
      Hi, Im either having a brain fart or I am misunderstanding
      would you mind explaining?
      is not working as I expect?
      Thank for the heads up. I had forgotten about immediate mode.
      Curious,
      thanks,
    • Sep 26 2007 | 9:45 pm
      On Sep 26, 2007, at 1:19 PM, vade wrote:
      > would you mind explaining?
      Below is a patch that demonstrates the basics, along with a little bit of fun. There are a few important things you were lacking:
      1. specify the modelview matrix mode 2. push/pop the modelview matrix before/after bang chain 3. use the drawraw message to any objects you are drawing. otherwise a variety of state is reset.
      Also, you need to make sure you don't dispose/recreate the window while this stuff is happening or else you could crash. immediate mode doesn't seem to be 100% safe at the moment for that case. Let me know if it still isn't clear.
      Anyway, this is basically the model GEM uses from what I understand, and can be simulated with abstractions, without much overhead. FWIW, in Jitter 2.0, we are definitely going to think about issues of hierarchy, but not within this procedural bang chain model.
      -Joshua
    • Sep 26 2007 | 9:48 pm
      p.s. jit.gl.mesh will be *oodles* faster for cases like the one Yair was actually interested in, and AB's solution would be recommended. If using the geometry many times in the sort of iterative jit.gl.gridshape case, use @displaylist 1, for performance improvements.
      -Joshua
    • May 06 2008 | 9:33 am
      revisited the formulas, added rotation origin math and visualization
      On Thu, Sep 27, 2007 at 12:48 AM, Joshua Kit Clayton wrote:
      > > > p.s. jit.gl.mesh will be *oodles* faster for cases like the one Yair was > actually interested in, and AB's solution would be recommended. If using the > geometry many times in the sort of iterative jit.gl.gridshape case, use > @displaylist 1, for performance improvements. > > >
    • May 07 2008 | 9:33 am
      Quote: yair r. wrote on Tue, 06 May 2008 10:33 ---------------------------------------------------- > revisited the formulas, added rotation origin math and visualization
      interested in seeing the patch, but there seems to be some problems with copy + paste... perhaps some forum patch scrambling?
      thanks,
      j
    • May 07 2008 | 9:45 am
      here ya go
    • May 12 2008 | 3:12 pm
      thanks, but still cant open.... is it done in max v5? am going to update sometime this summer, still have projects i need to finish!
      j
    • May 01 2010 | 7:07 pm
      Hi Yair,
      Would you mind reposting your patch because there seems to be some problem with the copy / paste ?
      cheers !