1 Reply Latest reply on Oct 7, 2014 5:05 AM by Matt Groening

# Distance between two points

Hi,

We have two MathPoints converted from screen coordinates in this manner (C#):

MathPoint screenPoint1 = _mathUtility.CreatePoint(new[]{x1, y1, 0});

MathPoint modelPoint1 = screenPoint1.MultiplyTransform(_modelView.Transform.Inverse());

MathPoint screenPoint2 = _mathUtility.CreatePoint(new[]{x2, y2, 0});

MathPoint modelPoint2 = screenPoint1.MultiplyTransform(_modelView.Transform.Inverse());

We want to calculate the distance between this two model space points. How can we accomplish that?

Right now we've tried to get the distance this way:

MathVector distanceVector = modelPoint2.Substract(modelPoint1);

But if we supply this distance as a parameter for  translation:_modelView.TranslateBy(distanceVector.X, distanceVector.Y)

var dvdata = distanceVector.ArrayData as double[];

_modelView.TranslateBy(dvdata[0], dvdata[1]);

The model translates not by the distance we've expected but by some significantly smaller one.

How we can calculate the distance between two points so after TranslateBy(x, y) the model will be translated as much as point1 appears at point2?

• ###### Re: Distance between two points

are you sure that your modelpoints are right?