How could I transform a point based on Normal?

   6502   7   0
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Hi;
As you can see in my attached image, I have a point on a surface.
Using point wrangle I found a primitive on a sphere, then I retrieved that primitive's Normal, and …
Problem is: When I try to move that point along it's local axis, it moves along XYZ of wold axis.
How could I covert it's movement from World to Local axis?

Thanks.

Attachments:
Transform.jpg (110.8 KB)

Masoud Saadatmand (MSDVFX)
User Avatar
Member
323 posts
Joined: Jan. 2015
Online
Hi Masoud,
dot product and cross product (vector math) are maybe your friends here. Sounds more complicated as it is.
Its also not 100% clear what you want to do.

regards

Olaf
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Thanks Olaf;

I want to change Transforms of my point from World to Local. For example, when I move the point in X axis, it moves along World X axis, but I need it moves along it's Local axis.

Attachments:
Capture.JPG (190.1 KB)

Masoud Saadatmand (MSDVFX)
User Avatar
Member
648 posts
Joined: July 2005
Offline
see attached…

Attachments:
localxform.hiplc (138.5 KB)

User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Hi “cpb”;

Thank you, but my problem is not to retrieve Normals of scattered points.
Here is what I want to do:
1) I create some points on a geometry using scatter.
2) Then I find a primitive near to each point, and I assign the Normal of that primitive to that point.
int PrimNumber;
vector Prim_uv;
float maxdist = 5;
xyzdist(1, @P, PrimNumber, Prim_uv, ch("MaxDist"));
if (PrimNumber!=-1)
{
    @N = prim_normal(1, PrimNumber, Prim_uv);
}
@P.x += ch("x"); 
@P.z += ch("z"); 

3) Now I want to move scattered points. So I tried to use:
@P.x += ch("x"); 

The problem is: it moves the point along World X-axis.

I attached my file here.
Edited by Masoud - Oct. 19, 2017 03:20:10

Attachments:
Test.hip (98.3 KB)

Masoud Saadatmand (MSDVFX)
User Avatar
Member
648 posts
Joined: July 2005
Offline
take a look at the colored SOPs, try changing the ‘move x’ slider…
its transforming the points along vectors set by ‘set_x_and_y’ SOP.
also scatter gives you the normals for free.
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
This will move the scattered points parallel to the primitive the normal is coming from:
int PrimNumber;
vector Prim_uv;
float maxdist = 5;
xyzdist(1, @P, PrimNumber, Prim_uv, ch("MaxDist"));
if (PrimNumber!=-1)
{
    @N = prim_normal(1, PrimNumber, Prim_uv);
}

v@x = normalize(cross(@N, @P)); // Find the axis perpendicular to the normal
v@z = normalize(cross(@N, @x)); // Find the axis perpendicular to the plane @N @x
@P += @x*chf('X');
@P += @z*chf('Z');

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Thank you “Bonsak”;
It works fine for me.

—————————–
and
Thank you “Cbp”, too;
You solution is great, but to be honest I didn't understand how it works. So I began to read about “VEX SOP geometry node” that you used in you solution.

—————————–
I used the code as Bonsak said. now each points moves along it's axis. But now new problem is I need to align all point's X axis to same direction.
Masoud Saadatmand (MSDVFX)
  • Quick Links