Question

Before everyone jumps on me for outsourcing my homework, my question is not a question on my homework. I'm just having a problem getting some stuff to draw properly.

I'm trying to draw lines perpendicular to a plane. I know the three points in space the make up the plane. From those coordinates I can calculate vectors and get the normal vector of the plane. Using the coordinates from the center of the three points and the normal vector I can draw a line perpendicular to the plane.

My problem is that the length of that line is tied to the normal vector because I'm just adding the vector to the coordinates to get two points to draw a line on. Without using some hideous brute-force code how do I draw a line of fixed length given any point in 3D space and any vector.

(I'm asking here because I don't know terms to use to search on google, my textbook doesn't have anything dealing with this, and my professor isn't going to be available before this is due.)

Was it helpful?

Solution

You need to 'normalise' your normal vector..

to do that, divide the vector by its magnitude.

the length, or magnitude, of vector r is given by:

                  
l = √ x2 + y2 + z2

you then divide r by its length (ie by dividing each component thereof ) giving

n = { x/l, y/l, z/l }

that will give you a new normal vector of length 1.

you can then multiply that by any length you desire.. to achieve any size line you require

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top