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

]]>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

]]>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

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

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

]]>MathieU

]]>MathieU

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

Thanks again.

Nick

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

Thanks again.

Nick

]]>“get linksLenghts”

Just to be clear.

]]>(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.

]]>