Jump to content

Align card with vector


Recommended Posts

55 minutes ago, Aizatulin said:

Hi,

one way might be using the sample covariance matrix of the geometry points and calculate the eigenvectors. These vectors can be used to align the geometry along x,y,z.

alignToVector.hipnc

Hey, Thanks for the reply!

Really appreciate it.

For now looking at it, if looks way over my head in vex and python.

So I don`t really know how to transform it back to original orientation. Also it doesn`t work when scaled down. and when I rotate the original card if flips from one side to another.

Just t clarify what I`m after. Im gonna have multiple cards around geo that I want to rotate and scale if for each loop. So my idea was to bring each card to origin align with XY axis then just use transform for scale and rotation, and then apply transforms back to card to get it back to original position and rotation(with new roation ac scale on top of those transforms).

Similar to this effect. just want to have control on scale and rotations based on normals from geo.

Cheers

Janis

Link to comment
Share on other sites

Hi,

here is another version. In the first version I've used @P -= Center again, which was wrong. It has to be += and if you want the geometry to copy to another geometry this center should be the root.

It is better, that this root is zero vector.

There is another problem. The geometry is flipping, if you change the orientation. I will take a look at it later.

alignToVector2.hipnc

  • Thanks 1
Link to comment
Share on other sites

10 hours ago, Aizatulin said:

Hi,

here is another version. In the first version I've used @P -= Center again, which was wrong. It has to be += and if you want the geometry to copy to another geometry this center should be the root.

It is better, that this root is zero vector.

There is another problem. The geometry is flipping, if you change the orientation. I will take a look at it later.

alignToVector2.hipnc

Thanks. this works nicely(apart from flipping)

Just not sure how to do rotation and scaling and  then transform card to original position.

Thanks for the help!

Link to comment
Share on other sites

3 hours ago, Yader said:

And here's another example, utilizing existing sop nodes instead of custom VEX :)

Disable the Channel SOP for tweaking, as recalculating the delay effect takes its computational toll...

image.thumb.png.01103824ef6bd13d8b3803b6cb07f47d.png

ezgif-7-efd5ce1f377d.gif

Feather_Mystique_01.hiplc

These new nodes in H18 are gold! Orientation along curve!. shame can`t use 18 for this project. So doing this vex .

Cheers

Link to comment
Share on other sites

59 minutes ago, Aizatulin said:

Here is fixed version, where all orientation nodes are wrapped together into one node.

The only input is a base(root) point parameter, which has to be defined.

The flippings problem seems to be solved now.

It looks like, that copy to points works with it.

cov_eigenB.hipnc

Dude you`re a legend!

Thanks a lot for this.

It`s gonna take some time for me to go through all the wrangles and understand how exactly it`s working :D

But it works good. apart from cards flipping.

I`ll upload part of my setup so it`s more clear what I`m doing.

I kinda made it work with building a polyframe and rotating,

This tutorial helped me a lot with trying to understand matrices and so on: 

 

but it rotation work only on one axis and when I try scaling it acts bit funky (RotX and scaleY works nice).

That is why I thought bringing it to center. do all the rotations and transforms there and then transform it back to world space(for each card) would be a better solution.

5e34a0332e1a4_Annotation2020-01-31163351.thumb.png.625c0d80e51949c3596225914247e008.png

 

Cheers

Janis

cov_eigenC.hipnc

Link to comment
Share on other sites

 

The flipping problem was due numerical inaccuracy. The problem is to get 4 points which are not in a plane. If the points are too close together following calculations may fail.

Once you are sure you have 4 points (with pt id), which are not in plane you can use them to avoid the flipping problem.

But anyway - I think for your problem this is not the best solution, because it is very time consuming. I like Thomas solution, because he is using the information of the surface to get the orientation and using point wrangle, which is quite fast.

If you have no other Information about Orientation this may be the only option or perhaps there are better solutions.

Just for completeness here is another file. I've changed a bit:

  • there is an input for eps (accuracy) too small or too big values will not work
  • the node outputs the transformation matrices for backtransformations
  • I've added an example bend node with custom parameters based on foreach values and distance functions

Generally foreach offers more flexibility than parallel point wrangle or hard coded nodes, but in many cases it has less performance.

 

P.S. just as a quick and dirty method: to incease the performance you can also loop once over the geometry and save all necessary attributes into detail arrays referencing to each class.

Using these attributes you can transform each point (which shoud have a unique class) to X,Y,Z, perform your operations and transform it back.

Here is another modified example ("cov_eigenE")(which will probably not work for every situation just more to visualize what I mean).

 

cov_eigenD.hipnc

 

cov_eigenE.hipnc

Edited by Aizatulin
  • Thanks 1
Link to comment
Share on other sites

In general i avoid "for-each" networks, it usualy becomes to slow. And when things get slow, art directing and creativity get worse. You can make hda's of your vex setups and then it gets as easy to use as a node. You can get a long way with learning how to use vectors, matrixes and quaternions.

Curve_bend.gif

unfoldBuild_06.gif

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Thanks for all the help guys. Lots of files and setups to learn from.

I ended up just getting rot axis Vector(using N and up vector) and getting orient attribute with quaternion function. As this seems like the easiest way to rotate.

I bring each card to the center so I use transform just to scale them up uniformly.

5e39950344a6e_rotAxis.thumb.png.706ea60b3c47c9c1eee6f057c5c4b15a.png

Cheers

Janis

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
For some of my personal work, i will like to be able to rotate, some piece along their most suitable candidate edge, and for this using some curve generate by shortest path like here or maybe gradient field.

i guess i will have to simplify the edge also off course to get some kind of median axis.
tIm not familiar with eigen, covariant matrice , probably i guess i have to use dot product once i make an approximation of the main edge of every piece and compare the normal or each to the tangent of the closest path or so...

Any TD around which might feel more comfortable here with the maths and don't mind to give a try this puzzle challenge? smile.png

Anyone please ?

Hip attached

@Aizatulin @ThomasPara @f1480187

ezgif-3-0c6ef0687593.gif

piece_to_orient_curveguide.hip

piece_to_orient_curveguide.hip

@konstantin magnus@petz@k2p8

 

Edited by vinyvince
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...