PDA

View Full Version : extend 2 point line in z axis


Demiantje
02-22-2012, 11:34 AM
Hello,

I am wondering how i can extend a 2 point line for example by 10 cm.
the points dont contain any directions, so a vector has to be made.
I think this is done by (P2 - P1), but then.

See the image below.
http://www.rinaldovreeken.nl/temp/extend_point.jpg

Demiantje
02-22-2012, 12:38 PM
Hi,

just found the solution.
here is the example code. i almost had it correct, just had to normailze the vector so it would have a value of 1.

new_point = vertex_array[2] - vertex_array[1]
new_point= normalize new_point
afsteun = vertex_array[1] + (-10 * new_point)

3ak
02-22-2012, 02:13 PM
fn moveP2 p1 p2 dist =
(
p3 = p2-p1
p1 + p3*(1+(dist/(length p3)))
)

CGTalk Moderation
02-22-2012, 02:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.