random vector around an axis

   2836   2   0
User Avatar
Member
143 posts
Joined: July 2015
Offline
Hello

I want a random unite vector from a point along Its normal and with arbitrary angle ( like a cone ).
I was expecting “sample_hemisphere(vector center, float bias, vector2 u)” does the trick cause It has bias but couldn't get the desired result.

should I write my own code to do this or there is a commend that I can use in wrangle?

thank you
User Avatar
Member
8 posts
Joined: Sept. 2016
Offline
Hello,

This tutorial may help you: https://vimeo.com/226167508 [vimeo.com]
If not, please share some more information on what exactly you want to achieve.

Have a great day!
User Avatar
Member
359 posts
Joined: April 2017
Offline
Try sample_direction_cone():

vector axis = @N; // cone pointing axis
vector2 u = rand(ch("seed")); // random unit vector2
vector out_v = sample_direction_cone(axis, radians(ch("angle")), u);

You can also use the Attribute Randomize SOP to handle this… or, if you want to stay in VEX, crack that SOP open and check out the wrangle inside. The code is a bit complex but you might get some good ideas from it.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
  • Quick Links