[PD] Free rotation in GEM

cyrille henry cyrille.henry at la-kitchen.fr
Thu Jul 17 18:05:20 CEST 2008


hello,

yes, there was a small bug in your algo.

it's easier for me to make a patch than to explain the problem.
so, i think this is what you need.

cyrille


PSPunch a écrit :
> 
> Cyrille,
> 
> 
> With your advise, I think I've successfully implemented the algorithm I 
> had in mind.
> 
> The sad thing is, the algorithm I imagined did not exactly function in 
> the way I wanted.
> 
> i.e. 1,
> during one "drag session", when rotating the Y axis (dragging right or 
> left) 180 degrees and then the x axis (up or down), it rotates as 
> expected. However, when moving the axis in reverse order (making the 
> teapot upside down, and then rotate) it does not rotate in the expected 
> direction.
> 
> i.e. 2,
> Behavior when dragging from one corner diagonally across the screen is 
> not as expected.
> 
> I've attached a sample patch.
> 
> 
> Probably the two problems are related. I need to look into this a bit 
> more..
> 
> -- 
> David Shimamoto
> 
> 
>> ok.
>> i think i undersand.
>>
>> there is an other possibility based on the gemlist_info object that 
>> get curent transformation matrix and convert it to rotation / 
>> translation ...
>>
>>
>> so, what i think is the most simple is :
>>     gemhead
>>     |
>>     rotateXYZ (for the drag rotation, should be (0 0 0) when you don't 
>> drag)
>>     |
>>     rotateXYZ (for a feedback loop thanks to the rotation given by by 
>> the last object on the chain)
>>     |
>>     object primitive
>>     |
>> gemlist         (the gemlist should be banged only at the end of the 
>> drag)
>> |
>> gemlist_info (get curent rotation at the end of the drag, and send it 
>> to the 2nd rotate)
>>
>>
>> you can save few cpu using gemlist_matrix and GEMglMultMatrix.
>>
>> this is a bit like the algorythm you describ, execpt that everything 
>> is computed on the GPU (it is more the Gem way to do).
>>
>> cyrille
>>
>> PSPunch a écrit :
>>> Hi,
>>>
>>>
>>> My primary goal is to place an object you can rotate by dragging the 
>>> mouse.
>>>
>>>
>>> Basically, whenever the mouse is clicked to start drag, I want to 
>>> rotate the object on the X & Y axises. Up to this point is no 
>>> problem, but I want the rotation to begin assuming the direction of 
>>> the viewer being the bases of the axis.
>>>
>>> Using one [rotate] object, I can get the object to rotate in the 
>>> behavior I expect only on the first drag.
>>>
>>> Ideally, each time the mouse button is released, the base (fundus? 
>>> basal?) of the rotation vector should be updated... I think.
>>>
>>> By chaining [rotate] objects, I can use one to rotate the rotation 
>>> axis and another to rotate the object from that point.
>>> However, I have not found a method of summing multiple drag actions.
>>>
>>>
>>> Although I may be wrong, I think what I need to do is,
>>>
>>>
>>> 1. Prepare two rotation axises
>>>     I. Angle of the axis
>>>     II.Angle of the current drag session
>>>
>>> 2. When the mouse button is clicked, rotate object to
>>>     angles I + II
>>>
>>> 3. When the mouse button is released, sum I + II and wait for
>>>     a new click.
>>>
>>>
>>> And again, although I may be wrong, my current understanding is that 
>>> step 3 will require multiplying the X-Y-Z angles converted to 
>>> quaternion, or some other method which will rotate the Z axis at some 
>>> point by summing rotations based only on the X&Y axises.
>>>
>>>
>>> Using procedures completely different from the one mentioned abouve, 
>>> I was able to achieve the expected behavior based on [accumrotate] 
>>> but I found no simple way of managing the current angle.
>>>
>>> Unfortunately I have torn down the patch. If it would clarify 
>>> anything, I will try to put together another one later today.
>>>
>>>
>>> Thanks for replies.
>>> -- 
>>> David Shimamoto
>>>
>>>
>>>> Indeed,
>>>>
>>>> Seems to me all the matrix discussion does not get to the heart of the
>>>> question.
>>>>
>>>> So, Pspunch, what are you really trying to do?
>>>>
>>>> I agree with cyrille that It's very likely the normal rotation objects
>>>> will do what you want it to.
>>>>
>>>> If you are just wanting to rotate many times, using huge numbers then
>>>> tricks like: wrap 0 359 work well...
>>>>
>>>> ..b
>>>>
>>>> cyrille henry wrote:
>>>>> hello
>>>>>
>>>>> sorry if i misunderstand.
>>>>> rotateXYZ will rotate in X direction, then in Y, finally in Z.
>>>>> if you wish to rotate in Z, then in X, you just need 2 rotate objects:
>>>>> the 1st for the rotation in Z, then an other for the rotation in X.
>>>>>
>>>>> anyway, there is no matrix manipulation that i was not able to do 
>>>>> with rotate/rotateXYZ/translateXYZ/scaleXYZ/shearXY..
>>>>> so i'm quite sure you don't need anything else than this standard 
>>>>> objects for simple matrix rotation.
>>>>>
>>>>> so i think you need 1 [rotate] to rotate the vector axis of the 
>>>>> object, then a accumrotate.
>>>>> if i misunderstood, could you please describe your problem better.
>>>>>
>>>>> I think you can also use GEMgl objects to multiply the matrix with 
>>>>> a custom one, but it's to much complex for what you need.
>>>>>
>>>>> cyrille
>>>>>
>>>>>
>>>>>
>>>>> PSPunch a écrit :
>>>>>> Hi Mathieu,
>>>>>>
>>>>>>
>>>>>> I have not looked into GridFlow much, but I had the impression 
>>>>>> that its main concept was to add matrix manipulation features to 
>>>>>> Pd, all of its visual capabilities being just one of the many 
>>>>>> results of data you can manipulate with matrix. (or is the egg 
>>>>>> first?)
>>>>>>
>>>>>>
>>>>>> Anyway, understanding its marvelous potentials, I have lately been 
>>>>>> stuck with Windows platforms. At least I got your point that 
>>>>>> utilizing GridFlow only for crunching numbers may work but not so 
>>>>>> efficient.
>>>>>>
>>>>>>
>>>>>>
>>>>>> What I am trying to do is rotate the vector axis of the object 
>>>>>> before applying [rotation]. This also calls for a method of 
>>>>>> summing the rotations when applying multiple times (and my current 
>>>>>> understanding is that this can only be done by multiplying the 
>>>>>> quaternion on each rotation)
>>>>>>
>>>>>> If there is no solution at the moment, perhaps Gem could use a few 
>>>>>> extra objects to ease advanced rotations?
>>>>>>
>>>>>> I feel like I am complaining about lack of features without 
>>>>>> pointing out what exactly is missing, when I should be blaming my 
>>>>>> lack of math skills.
>>>>>>
>>>>>> hmmm..
>>>>>>
>>>>>> -- 
>>>>>> David Shimamoto
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On Wed, 16 Jul 2008, PSPunch wrote:
>>>>>>>
>>>>>>>> Trying to achieve free rotation *without* using [accumrotate], I 
>>>>>>>> have
>>>>>>>> come across concepts such as multiplying matrixs and converting 
>>>>>>>> a matrix
>>>>>>>> to "quarternion"
>>>>>>>> How do you implement precise control of rotation matrixs?
>>>>>>>> Is this exactly what people use GridFlow for?
>>>>>>> If you tried GridFlow's bundled examples you'd see what I use 
>>>>>>> GridFlow for. I suppose that I could add some other people's 
>>>>>>> examples in the package, if they sent it to me for that purpose. 
>>>>>>> There is already one patch by Roman Häfeli in GridFlow's examples 
>>>>>>> though.
>>>>>>>
>>>>>>> GridFlow does not support quaternions. I bet it's possible to add 
>>>>>>> support for it using abstractions, but it wouldn't be fast. But 
>>>>>>> I'm willing to add it to the core... there's already a 
>>>>>>> complex-number section in number.c, why not quaternion product? 
>>>>>>> It would be called [# H.*] where H stands for Hamilton (in math 
>>>>>>> the letter Q is already reserved for rationals, so I'd use H even 
>>>>>>> though the concept of rational reasonably couldn't appear in that 
>>>>>>> particular place).
>>>>>>>
>>>>>>>  _ _ __ ___ _____ ________ _____________ _____________________ ...
>>>>>>> | Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec
>>>>>> _______________________________________________
>>>>>> Pd-list at iem.at mailing list
>>>>>> UNSUBSCRIBE and account-management -> 
>>>>>> http://lists.puredata.info/listinfo/pd-list
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> Pd-list at iem.at mailing list
>>>>> UNSUBSCRIBE and account-management -> 
>>>>> http://lists.puredata.info/listinfo/pd-list
>>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> Pd-list at iem.at mailing list
>>> UNSUBSCRIBE and account-management -> 
>>> http://lists.puredata.info/listinfo/pd-list
>>>
>>>
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rotate_test.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20080717/b4d1ff53/attachment.txt>


More information about the Pd-list mailing list