Cansisti
Cansisti

Reputation: 153

Upwards tangent vector of triangle in 3D space

I have a triangle in 3D cartesian space, it forms a surface. I have a normal vector of that surface. What I want to find out, is a vector tangent to that surface, which points the most "upwards". (The orange one on image, forgive my paint skills) enter image description here

Upvotes: 0

Views: 105

Answers (1)

MBo
MBo

Reputation: 80287

Let one triangle edge vector is A. Get perpendicular vector in the plane

P = N x A

and normalize P and A

p = P / len(P)    
a = A / len(A)

Any unit vector in the plane is combination of these base vectors

v = p * cos(t) + a * sin(t)      (1)

We want that Z-component of v to be maximal (as far as I understand most "upwards")

vz = pz * cos(t) + az * sin(t)    (2)

has extremum when it's derivative by t is zero

0 = (pz * cos(t) + az * sin(t))' = -pz * sin(t) + az * cos(t)
tan(t) = az / pz
t = atan2(az , pz)

put t values into (1) and get needed vector v

Upvotes: 0

Related Questions