Measuring Line length relative to vector direction

Hello all, I am looking for a way in which I might measure a line or set of lines against a provided vector direction.

For Context, my ultimate goal is to create a perfect sound-reflecting surface projecting from any relatively flat surface I choose, though I am currently limited to using surfaces built in the x-y-z planes, like in this examples here. If I were trying to generate a reflecting ceiling surface, for example, I take the distance between panels in the z direction and move them towards each other to close the distance, which is my process of creating a smooth reflecting surface. To get that Z-distance, I can use the deconstruct points component to take two points’ given z heights and subtract them from each other. The reason why it is important to measure against the z-axis in this case and not simply use the distance component is because it gives me up/down directionality of the distance, whereas the distance component only gives the absolute value of the distance. That directionality with the positives/negatives is important since some panels need to be adjusted either upwards or downwards.



So now that brings me to needing to measure distance like this relative to the direction of any provided vector. If we subtract given points a and b, for example, I need the resulting distance to be either positive or negative, depending on whether point b was in front of or behind point a relative to the directionality of my provided vector. This would allow me to generate the type of surface I am looking for, using plane surfaces of any orientation I choose. The script for my workup of sound reflections is quite large and messy, but I’m providing here a sample of the type of data I am trying to measure/organize. it has a provided vector and a set of curves which I would need to measure the distance of according to their directionality.

I could probably logic this out and come up with a complex working solution that will bog down the speed at which my script works, but I was first wanting to see if anyone had any ideas on how to do this in a fairly straightforward way that I’m missing. As a note, I would appreciate assistance with doing this with grasshopper components, given that I am not familiar with Python coding. If you need any other information, please let me know.
sample.gh (15.3 KB)

Line has an A start point and B end point.

Take point A, move in direction of vector B with a factor. Now you have a third point C and you can drow a second line AC.
Find the nearest point “D” on of B on the segment AC.
Distance between A and D is the lenght you want.

So sorry for my bad english, i hope the image is better!

I appreciate the idea, but this doesn’t really solve what I’m trying to accomplish. For what I am doing, line AB will already be moving in the same direction as/ will be parallel with the vector I am referencing. What I need is a way to make the measured distance between AB a positive or negative value, depending on where B is relative to A. Hopefully this sketch makes it a little more clear what I mean. You can see that the measured distance between the two points should be either a positive or negative value, depending on which one is “up” relative to the vector. With the Z axis, this was easy, since I could simply subtract the z height of point a from the z height of point b, which would give me that positive/negative value.

Hi,

You could use Plane Coordinates. Build a normal plane to your vector and use the Z output.

Ah, thats perfect. I can integrate it into my system very easily as well. Thanks, I wouldn’t have thought that there was such a component.

1 Like

By the way, if the reference vector is unitized, this is exactly the dot product of AB with the reference vector, which eliminates all the geometric construction.

Example with X :

DotProductMeasure.gh (11.8 KB)

2 Likes