We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I try to found the vector direction of tangent in 3D, but I'm locked. I find a path on internet but no one give me the solution. http://stackoverflow.com/questions/26164521/how-is-calculating-the-unit-tangent-vector-of-a-normal-vector-in-3d http://stackoverflow.com/questions/5928490/how-to-calculate-tangents-of-a-circle-in-3d http://blog.db-in.com/calculating-normals-and-tangent-space/
I find a story about the cross product but I don't find the other vector to put in cross(Vec 1, vec2) :(
PVector dir, tan ;
void setup() {
size(400,400,P3D) ;
dir = new PVector(random(-1,1),random(-1,1),random(-1,1)) ;
tan = new PVector() ;
tan = dir.cross(new PVector(-dir.y, dir.x,0)) ;
}
void draw() {
background(0) ;
noFill() ;
stroke(255) ;
strokeWeight(1) ;
int radius = 50 ;
PVector final_pos = new PVector(width/2,height/2, 0) ;
PVector pos_projection = new PVector() ;
PVector dir_temp = dir.copy() ;
pos_projection = dir_temp.mult(radius).add(final_pos).copy() ;
PVector pos_tan = new PVector() ;
PVector tan_temp = tan.copy() ;
pos_tan = tan_temp.mult(radius/2).add(final_pos).copy() ;
//display projection
line(final_pos.x, final_pos.y, final_pos.z,
pos_projection.x, pos_projection.y, pos_projection.z ) ;
// display tangent
line(pos_projection.x, pos_projection.y, pos_projection.z,
pos_tan.x, pos_tan.y, pos_tan.z ) ;
println(final_pos.x, final_pos.y, final_pos.z,
pos_projection.x, pos_projection.y, pos_projection.z ) ;
println(pos_projection.x, pos_projection.y, pos_projection.z,
pos_tan.x, pos_tan.y, pos_tan.z ) ;
}
Answers
There is no tangent vector in 3D instead there is a tangent plane.
In 2D is is simple to calculate the tangent line to a curve. If that curve is in 3D space there is no single tangent line rather a 'surface' that is at right angles to the curve.
In 3D if you have 2 distinct vectors then they define a plane (flat surface), the cross-product of the 2 vectors give you vector that is normal (at right angles) to the plane.
hmmm, you mean I must make a code like that :
Final code, I think that's work now thanks for the piece of advice quark !