[osg-users] transforming between coordinate systems of two subgraph

Glenn Waldron gwaldron at gmail.com
Fri Jul 17 05:06:31 PDT 2015


You can use a 3d or 4d vector. MatrixTransforms are usually (always?)
affine anyway so you don't need to explicitly make a Vec4d or divide by W
or anything.


Glenn Waldron / @glennwaldron

On Fri, Jul 17, 2015 at 4:29 AM, Christian Buchner <
christian.buchner at gmail.com> wrote:

> Also I think it has to be a 4 element vector (last element being 1.0), no?
> We're working in homogeneous coordinates here.
>
> I was having additional trouble because I noticed my chosen transformation
> objects were actually PositionAttitudeTransforms which don't derive from
> the MatrixTransform class (these PAT objects don't even provide utility
> function to return an equivalent transformation. But I got that sorted out
> eventually.
>
> Christian
>
> 2015-07-16 18:43 GMT+02:00 Glenn Waldron <gwaldron at gmail.com>:
>
>> NP. One more thing I forgot to mention. Convert coordB to a osg::Vec3d
>> first. Otherwise you risk losing precision. (Because geometry coords are
>> 32-bit float, while transform matrices are 64-bit double.)
>>
>> Glenn Waldron / @glennwaldron
>>
>> On Thu, Jul 16, 2015 at 12:36 PM, Christian Buchner <
>> christian.buchner at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> thanks a lot. Now that I've got the solution in front of me, I must
>>> say.... that was obvious ;)
>>>
>>> Christian
>>>
>>>
>>> 2015-07-16 17:35 GMT+02:00 Glenn Waldron <gwaldron at gmail.com>:
>>>
>>>> coordA = (coordB * matrixTransformB->getMatrix()) * matrixTransformA
>>>> ->getMatrix().inverse();
>>>>
>>>>
>>>>
>>>> Glenn Waldron / @glennwaldron
>>>>
>>>> On Thu, Jul 16, 2015 at 11:23 AM, Christian Buchner <
>>>> christian.buchner at gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I was having some problems with a coordinate transformation.
>>>>>
>>>>> root
>>>>> matrixTransformA      matrixTransformB
>>>>> subgraphA                subgraph B
>>>>>
>>>>> I have two subgraphs in my scene, each of which is a child of a unique
>>>>> MatrixTransform.
>>>>>
>>>>> I now have to draw a line between an element from subgraph A to
>>>>> connect to an element of subgraph B. I've decided to add this line into
>>>>> subgraphA as a drawable - so both start and end point of this line have to
>>>>> be specified in my "A" coordinate system.
>>>>>
>>>>> How would I transform a coordinate from subgraph B coordinate system
>>>>> into the equivalent
>>>>> coordinate valid within subgraph A, ideally using utility functions
>>>>> provided by the OSG framework ? I would like to do that with minimal amount
>>>>> of code.
>>>>>
>>>>> Excuse me for asking a basic linear algebra question, but I seem to be
>>>>> stuck for good on this problem.
>>>>>
>>>>> Christian
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> osg-users mailing list
>>>>> osg-users at lists.openscenegraph.org
>>>>>
>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> osg-users mailing list
>>>> osg-users at lists.openscenegraph.org
>>>>
>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>>
>>>>
>>>
>>> _______________________________________________
>>> osg-users mailing list
>>> osg-users at lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150717/2e2d061c/attachment-0003.htm>


More information about the osg-users mailing list