Apply normal direction into a locator orientation, in OpenMaya? - maya

I have normal directions, is there some way to apply these values into a locator so this locator can point to the same direction of these normal values? It needs to be done in OpenMaya. Any suggestion?
Thanks a lot!

With MFnMesh you can retrieve the normals/positions of vertices/faces from a mesh, and use this data to construct the transformation matrix for each locator.
https://help.autodesk.com/view/MAYAUL/2019/ENU/?guid=__py_ref_class_open_maya_1_1_m_fn_mesh_html

Related

Ordering 2d/3d object behind other element

As you can see in the link, I have two elements: first is image element which is taken from camera (using EmguCV) and the other one is viewport3d which renders 3d object. I also include 2d object (see the rectangle).
When I run my program I see this.
Yes indeed, the object (hand) will be ordered in front of the image.
The question is how to order 2d/3d object behind the hand object? Is it possible to do it using single camera? Just like this one.
Thanks in advance for your answers.
There are two ways of doing it.
Use kinect depth map to find the distance of hand from camera.
Do image processing to detect hand and it's distance.
I think it will be difficult to directly blend WPF UI with camera image.
Try RenderTargetBitmap
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx

Transformation to make a curve

Is there a way to create a matrix transform or any other transformation to bend a rectangular element on the screen? Say I have a long rectangle: width=50 and height = 500. And 2/3 of the way down I want it to turn 90 degrees.
Thank you!
I think what you're looking for are the various Geometry classes, especially PathGeometry.
These links are a good start:
http://msdn.microsoft.com/en-us/library/ms747393.aspx
http://msdn.microsoft.com/en-us/library/ms751808.aspx
You could use a pixel shader (effect in WPF), however this will render the hit test in that area useless.

How can I make the changes of a transformation stick?

So I have a FrameworkElement to which I apply a template that has a thumb. I calculate the angle and then I set the RenderTransfrom property equal to a RotationTranform. Once I do the rotation and want to do another rotation, the changes don't stick, that it the element returns to its initial position. How can I make the changes stick after a transformation has been applied. Any help would be appreciated. Thank you.
Do transformations affect the actual element or are they only a rendering thing? Also do they affect the bounding box of the element? I tried a layout transformation and still the same result.
You can only have one tranform at a time, but if you need multiple transfomations you can use a TransformGroup to add whatever transforms you need.
Alternatively you can use a MatrixTransform whose Matrix you can manipulate (those changes will not be reversible but as there is only one transformation in total it should have a higher performance).

Rectangle matrix calculations in OpenCV

I had a generalized question to find out if it was possible or not to do matrix calculations on a rectangle. I have a CvRect that has information stored in it with coordinates and I have a cvMat that has transformational data. What I would like to know is if there was a way to get the Rect to use the matrix data to generate a rotated, skewed, and repositioned rectangle out of it. I've searched online, but I was only able to get information on image transforms.
Thanks in advance for the help.
No, this is not possible. cv::Rect is also not capable of that, as it only describes rectangles in a Manhattan world. There is cv::RotatedRect, but this also does not handle skewing.
You can, however, feed the corner points of your rectangle to cv::transform:
http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=transform#cv2.transform
You will then obtain four points that are transformed accordingly. Note that there are also more specialized versions of this function, e.g. warpPerspective() and warpAffine().

Check for overlapping shapes in WPF

I have a set of shapes which need to be drawn on top of each other. I need to re-order them such that the smallest shape gets drawn last (i.e. it will be closest to the user). Is there any way to check whether a shape overlappes (encloses and/or intersects) another shape. I know there is a method in Rect structure called Contains which checks whether there is an object within it. Is there a similar method or a way to simulate it on Shapes in WPF? Thanks in advance for any help.
Cheers,
Nilu
You could probably use the Geometry.FillContainsWithDetail method. Its name is ill-chosen IMHO, but the description is clear :
Returns a value that describes the intersection between the current geometry and the specified geometry.
I have successfully used it for collision testing before, so it should work for you too...

Resources