Search - User list
Full Version: trying to create a center point from VECTORS
Root » Technical Discussion » trying to create a center point from VECTORS
Getyamamout
Hi
I am trying to get a point into the correct position. I have 2 points with normals and was assuming I could send a point 90degree from the pair to meet at a desired position. All I keep doing is getting a plain locked flat to the diverging normals.

vector P1 = point(0, "P", 0); // First point position
vector P2 = point(0, "P", 1); // Second point position
vector N1 = point(0, "N", 0); // First point normal
vector N2 = point(0, "N", 1); // Second point normal

vector edge = P2 - P1;

// Calculate a vector perpendicular to both normals
vector planeNormal = cross(N1, N2);

planeNormal = normalize(planeNormal);
[attach]help.png[/attach]

vector thirdPoint = cross(edge, planeNormal);

thirdPoint = normalize(thirdPoint);

float distance = 1.0;
thirdPoint *= distance;

vector P3 = P1 + thirdPoint;

@P = P3;
Getyamamout
Well I got the position I wanted but not the way I had planed I have had to pass information in from further down the line to get an angle and length to use to find the position NOT ideal or what I was thinking. and a bit messy so would still be interested in some feed back.

float angle = point(1,'angB',@ptnum);
float len = point(1,'lenA',@ptnum) * (cos(radians(angle)));
f@l=len;
vector P1 = point(0, "P", 0); // First point position
vector P2 = point(0, "P", 1); // Second point position
vector N1 = point(0, "N", 0); // First point normal
vector N2 = point(0, "N", 1); // Second point normal

vector edge = P2 - P1;

// Calculate a vector perpendicular to both normals
vector planeNormal = cross(N1, N2);

planeNormal = normalize(planeNormal);

vector thirdPoint = cross(edge, planeNormal);

thirdPoint = normalize(thirdPoint);

float distance = len;//1.0;
thirdPoint *= distance;

vector P3 = lerp(P1,P2,0.5) + thirdPoint;
vector N3 = lerp(N1,N2,0.5);
@P = P3;
@N = N3;
removepoint(0,0);

the float distance had to be worked out from the edge and shifted over with a lerp
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB