How to adjust length of a line drawn between two lines?

I have a line that I have drawn between two points

origin = [1 0 2];
point = [1 -2.8 2.8 ];

I want to draw a line between them at a certain distance. I have tried the following, which gives me wrong results... Is there a better way to do this?

distance = 0.5;

point3 = origin + (point-origin) * distance;

Read more here:

Content Attribution

This content was originally published by George Lua at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: