# Move two points by their respective directional vectors to a fixed offset distance from a line?

Hi everybody,

I’m currently looking for a strategy to move two points, p1 and p2, by their respective directional vectors, v1 and v2, to a fixed offset distance d from line l.

The points p1 and p2 are the endpoints of the line l. The vectors v1 and v2 are unit vectors, and thus can’t be used directly to find the points p1’ and p2’ at the offset distance d from line l.

I know that I could construct an infinte line from p1 and p2 in the direction of v1 and v2, and intersect those lines with the offset infinte line at distance d from line l.

However, is there a simpler way? Could I for instance simply calculate the right vector lengths for v1 and v2 somehow? Any other suggestions?

Thanks!

I’m confused - don’t you just multiply the vectors by d?

The goal is to get the points, p1’ and p2’ (green), from the initial points, p1 and p2 and their respective directional vectors, v1 and v2, which are unit vectors.

Multiplying v1 and v2 by the offset distance d won’t work (cf. example). The distance d is measured perpendicular to the line l. Both vectors are not perpendicular to l, which means that there magnitude must be bigger or smaller than d, depending on their angles to the line l!

Above you can see the scaled vector v1’ with a magnitude of d. It doesn’t reach p1’!

OK I understand yes line l` is not the same length as line l and/or it is offset longitudinally as well as laterally?

The line length of line l and l’ shouldn’t be relevant here, but yes, both lines have only the same size if both vectors v1 and v2 are perpendicular to line l and thus l’!
Line l’ is the line between the points p1’ and p2’, which I want to find in the first place.

So the distance is 1/ cosine of the angle between the line marked d and the vector v1 / v2 ?

1 Like

No, unfortunately that doesn’t seem to work either.

Here’s the file with your proposition:
move_points_01.gh (17.3 KB)

@Dancergraham, thanks for the suggestions so far!

1 Like

Should be easy - but I can’t quite figure it out !!!

Don’t worry! Maybe somebody else can propose a solution?

what.gh (9.7 KB)
This is just a small concept…

Waiting until the seventh post in this thread before sharing your code/geometry is a very poor way to ask a question here:

move_points_2019Jul8a.gh (12.2 KB)

Hey dude, you are a prime example of why this forum needs an ignore function. Bye-bye.

This forum heavily relies on other peoples good will. Even if Joseph hasn’t been asked you should appreciate his effort.

This one is a way using Right Trigonometry, but not as simple as you might think…

Offset through Vector Directions_re.gh (15.0 KB)

2 Likes

I absolutely agree!

I would have appreciated @Joseph_Oster’s input, as I did @maje90’s suggestion, even though it also is what I specifically didn’t ask for, if he hadn’t started by throwing around false accusations that instantly debunked him as a hater (at least of this discussion).
And after my reply, calling out for censorship in the forum and simply manifesting that he now ignores me, seems like another piss-poor, childish approach. Be a man and face your mistakes!

Thanks @HS_KIm, I’m going to check it out. Looks promising!

@HS_Kim, the offset line doesn’t seems to be parallel to the initial line. Do you think this might be possible too with your method?

I didn’t check it much but you can compare the results with regular Offset.

It seems it won’t work in some cases. I’ll look into it.

1 Like

@HS_Kim, thanks.
It seems like there is also something wrong with the offset distance. You can see it by comparing both lines (same distance):

If I understand the question correctly, you are looking for the scalar multiplier for each vector which takes that end point to a line at some distance d from, and parallel to, your original line l
You can use dot product to get the length of the projection of one vector onto one perpendicular to l, then divide by this, like so:
dotproduct.gh (12.6 KB)

I think this kind of thing is covered in Rajaa’s guide:

2 Likes