Hi Paxton,

This is possibly not what you are looking for, as you asked for a coded
method, but Maya is quite capable of transforming points using a matrix via
its own nodes.

Have a look at the fourByFourMatrix, multMatrix and decomposeMatrix
nodes. You would connect the transform of your curve, or group of curves
into multMatrix along with thr 4x4 matrix, which would multiply, or
"transform" them using the 4x4. You could then use the decomposeMatrix to
extract the new translate, rotate and scale.

If you'd rather apply the new transformation to the points themselves, you
can use the output of multMatrix with a transformGeometry node which, given
a set of geometry, transforms the geometry using the inputted matrix.

This could potentially be used real-time, and I'm sure it's quite fast as
well.

On Sunday, May 4, 2014, Paxton <[email protected]> wrote:

> Hey guys. long time lurker, first post...
>
> I posted this over on stack overflow, but I think this might be a better
> place for it..
>
>
> I am creating a toolset for creating nurbs curves/surfaces inside maya
> using python.
>
> I have a set of dictionaries that include cvPositions, knots, form etc.
> each of which describe a preset 3d shape (cube, circle, pyramid etc). I
> also have a 3d matrix stored in the nodes metadata that is used as an
> offset for the shape. This allows you to scale/move/rotate the shape
> without moving the transform.
>
> The problem is in the way I am applying this matrix is very slow:
>
> First I will create a new (edit)transform at the position of the
> (orig)transform containing the curves. Next I will transfer cv positions in
> world space from (orig)transform to (edit)transform. Next i will move the
> (edit)transform into the matrix position. Finally I will world space
> transfer the cvPositions back to the (orig)transform
>
> When creating hundreds of shapes, this is becoming prohibitively slow...
>
> Can someone describe a mathematical way to apply a matrix to a set of 3d
> points? maybe using one of pythons math modules or perhaps numpy?
>
> Alternatively,
>
> Is there a way using OpenMaya api functions to do this? Perhaps with
> MPointArray? The following code block is about as far as I have gotten on
> that front:
>
> cheers,
>
> -Paxton
>
>     crv = OpenMaya.MFnNurbsCurve( self.dagPath )
>     cvs = OpenMaya.MPointArray()
>     space = OpenMaya.MSpace.kWorld
>     crv.getCVs(cvs, space)
>     positions = []
>     for i in range(cvs.length()):
>         pt = cvs[i]
>         positions.append( (pt[0], pt[1], pt[2]) )
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> [email protected]<javascript:_e(%7B%7D,'cvml','python_inside_maya%[email protected]');>
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/20487b33-cb96-4bd6-8b99-de2d6e02c73e%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/20487b33-cb96-4bd6-8b99-de2d6e02c73e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCpnb51yM%2BRAYQA4t3F2G41kNcs3bgJ1vPmvUcu5nAqbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to