Jump to content

transforming a Vex-built PolyLine


sasbom

Recommended Posts

Hello to all!

I am currently writing a wrangle-thing in which I'm hoping to generate a random "hair" on every point and make it face the normal of said point.

The way I planned it is as follows:

1. create the hair w/ random params on 0,0,0

2. rotate the hair to Normal of the point that it's "generated on" w/ rotate(matrix,angle,vertex) function

3. Move the hair to @P

I'm not a hero with vector math, otherwise I'd generate the whole hair thing along a normal.

I wonder if I somehow can construct a identity matrix, like one would do with the ident() function, and use that to transform the prim.

Is there a way to simply rotate a primitive using something simpler than extreme vector math?

sgamhar.hip

Link to comment
Share on other sites

On 6/6/2018 at 5:52 PM, Yon said:

Just create a point at the same position and displace by normal @P += @N (or multiply) and connect them

Could you explain a little bit more?

I don't quite get it...

Does the displace by normal take care of origin-based rotation? I guess it'll have to be multiplication then.
I'll try it out, at least what I can make of your advice!

Link to comment
Share on other sites

Ah, I finally get what you've been trying to tell me. That part would've gone in the actual "hair grower" part of the algorithm, but the thing is that I can't use that because I have a twirl thing based 
on some simple goniometric mathematics. 

I'll be doing more experiments and trying things out.

I'll probably end up making every hair a new primitive, and using a primitve wrangle after that to wrangle them in the correct spot.

Link to comment
Share on other sites

Hello to all. I solved the math problem, ended up using the qrotate function together with quaternion in vectoraxis mode.

I botched it a bit using the normal as the axis, multiplying it slightly, and then correcting the angle based on wether the dot product of the Normal and the up vector was positive or negative.

I'm stoked this even works. I love houdini for its "multiple ways to rome" capabilities.

I still don't understand nothing about quaternions but this at least gives me a vague ideo on how to use them.

Thanks again for the help. I've included what I have now, to share with everybody.

 

--

 

I did it even more properly now, using the dihedral function. This is WAY less hassle than before.
I knew this function existed, but I never saw the use for it until now.
the basic structure goes like this:

//define original vector (our line "grows" on the Y axis)
vector known_vector = set(0,1,0);

//compute what kind of rotation it would take to rotate points from the first vector (in our case {0,1,0} since the built line goes up), to the normal vector.
vector4 rot_quaternion = dihedral(known_vector,@N);

//rotate point position into place
position = qrotate(rot_quaternion,position);

so easy. so perfect. Math is amazing.

I've implemented it and uploaded the file, so take a look if you want.

sgamhar_3.hip

Edited by sasbom
I have learned more and wanted to elaborate.
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...