## MSD Link Length

Oct 29, 2009 at 2:58pm

# MSD Link Length

Hello,

If I have the X,y coordinates for 2 points in a graph (the range of which is -4 to 4) how do I measure the distance between them?

I appreciate that this may be a very simple trig problem but, shamefully, I am useless when it comes to maths. If only someone had explained the wonderful relationship between maths and music when I was at school I would have paid so much more attention!

The Context:

I am using the MSD library. I have created one mass which is attached by an elastic link to another. When one mass moves the other bounces around it thus creating a fun 3D interface. The link position is defined by four values (2 X and 2 Y). I want to use the link length as control data for a parameter on a synth.

I really appreciate any help you can give me with this one. I will say it to save you all the trouble…”I am dim as a bag full of arses for not knowing how to do this”.

Nick

#46202
Oct 29, 2009 at 3:02pm

[quote title=nick williams wrote on Thu, 29 October 2009 14:58]Hello,

The link position is defined by four values (2 X and 2 Y).

^^ Sorry, that should read “(2 PAIRS of X,Y values)” defining the start point and end point of the line on my graph.

Cheers,

Nick

#166399
Oct 29, 2009 at 3:02pm

[quote title=nick williams wrote on Thu, 29 October 2009 14:58]Hello,

The link position is defined by four values (2 X and 2 Y).

^^ Sorry, that should read “(2 PAIRS of X,Y values)” defining the start point and end point of the line on my graph.

Cheers,

Nick

#166409
Oct 29, 2009 at 3:57pm

> If I have the X,y coordinates for 2 points in a graph (the range of which is -4 to 4) how do I measure the distance between them?

You should browse Pythagore, and find what is the squared hypothenuse to know it.

#166400
Oct 29, 2009 at 3:57pm

> If I have the X,y coordinates for 2 points in a graph (the range of which is -4 to 4) how do I measure the distance between them?

You should browse Pythagore, and find what is the squared hypothenuse to know it.

#166410
Oct 29, 2009 at 4:28pm

if you create a link between your 2 points, you can then use the “get linksLenghts” message to msd ; it will return links lengths = distance between points…

MathieU

#166402
Oct 29, 2009 at 4:28pm

if you create a link between your 2 points, you can then use the “get linksLenghts” message to msd ; it will return links lengths = distance between points…

MathieU

#166411
Oct 29, 2009 at 6:30pm

Thank you both for your helpful replies. The “getlinklength” message is exactly what I’m after. I don’t know how I missed that one after studying the help file so much. Doh!

I have been brushing up my trig but clearly have some work to do. Next stop “Squared Hypotenuse”!

Thanks again.

Nick

#166403
Oct 29, 2009 at 6:30pm

Thank you both for your helpful replies. The “getlinklength” message is exactly what I’m after. I don’t know how I missed that one after studying the help file so much. Doh!

I have been brushing up my trig but clearly have some work to do. Next stop “Squared Hypotenuse”!

Thanks again.

Nick

#166412
Oct 29, 2009 at 6:43pm

For anybody else that is trying the link length message note that the message must be typed with the incorrect spelling e.g “Lenghts”. Thus the correct message is:

Just to be clear.

#166413
Oct 31, 2009 at 12:08am

Nice that there’s a function to get it for you, but this is a good one to know anyways… from the days of Pythagoras and probably years before that.

(x1, y1) and (x2, y2) –> your points

differences: (x2 – x1) and (y2 – y1)

square each of these results: (x2-x1)^2, (y2-y1)^2

take the square root of their sum.

so… if your points are (0,0) and (4,3), then the distance is

square root ( (4-0)^2 + (3-0)^2 ), or square root (16 + 9), or 5. yes that was an integer one.

if it all sounds Greek, just do it visually, and turn the sides of your triangle into square grids. it’ll be more clear.

in Max, in expr, with your four points as floats:

expr sqrt ( pow((\$f2-\$f1), 2.) + pow((\$f4-\$f3) , 2.) )

i think the syntax is right… yes it does start to look messy, the backslashes are for Max to deal with commas.

#166414

You must be logged in to reply to this topic.