TheSwamp

Code Red => .NET => Topic started by: www1970 on July 26, 2006, 11:38:27 PM

Title: if exist coordinate transform function in using VBnet
Post by: www1970 on July 26, 2006, 11:38:27 PM
if exist coordinate transform function in using VBnet, like "polar" function in Autolisp
example: i want get a point3d coordinate from another point3d
Title: Re: if exist coordinate transform function in using VBnet
Post by: MickD on July 27, 2006, 12:52:13 AM
I'm not sure if this is what you want but you can get the point in relation to another point using a vector.
eg.

Vector3d vec = pnt1.GetVectorTo(pnt2); //get vector from point to another point:

Point3d newpnt = new Point3d(vec.X, vec.Y, vec.Z); // get the values from the vector into a new point, if needed.

Is that any good?

Title: Re: if exist coordinate transform function in using VBnet
Post by: Kerry on July 27, 2006, 03:34:30 AM
Close Mick,

the polar function takes 3 arguments

From_Point
Rotation_angle
Distance_along_angle_path

returns the calculated point, in the current UCS
Title: Re: if exist coordinate transform function in using VBnet
Post by: MickD on July 27, 2006, 04:18:50 AM
Ah, I see.
In that case you could create a vector, multiply it by the distance and then rotate it by the given angle and extract its values for your new point.
Yes?
Title: Re: if exist coordinate transform function in using VBnet
Post by: Kerry on July 27, 2006, 05:36:42 AM
That would probably be faster than calcing cos and sin of the distance and summing the values with the origin X & Y  .. might make an interesting test ..

The COM interface is probably not worth considering. < that was a question, I think >
Title: Re: if exist coordinate transform function in using VBnet
Post by: MickD on July 27, 2006, 05:48:24 AM
Actually, there would be one more calculation.
You would have to add the original point.AsVector() and the new vector to get the vector to the new point, that would be the correct result.
A vector of a given length and angle only gives just that, angle and length, not position in space.
Title: Re: if exist coordinate transform function in using VBnet
Post by: Kerry on July 27, 2006, 05:50:56 AM
Something like ..
Code: [Select]
public static Point3d GetPolarPoint(Point3d ptBase, double angle, double distance)
{
      return new Point3d(ptBase.X + (distance * Math.Cos(angle)), ptBase.Y + (distance * Math.Sin(angle)), 0);
}

... UNTESTED ..

Title: Re: if exist coordinate transform function in using VBnet
Post by: www1970 on July 27, 2006, 05:55:13 AM
Kerry Brown

That would probably be faster than calcing cos and sin of the distance and summing the values with the origin X & Y  .. might make an interesting test ..


what is  "That" ?
Title: Re: if exist coordinate transform function in using VBnet
Post by: Kerry on July 27, 2006, 05:59:03 AM
"That" was the option of using vectors ....

.. BUT, I've changed my mind ..
.. I think the code I posted < if it works :-) > may be faster .

kwb



Ooooops ... that was C# you can translate ..! :-)
Title: Re: if exist coordinate transform function in using VBnet
Post by: MickD on July 27, 2006, 06:06:00 AM
yes, it looks like it. I was thinking in 3d, so your example Kerry may still be quicker although a bit more complicated 'looking' in code.
Title: Re: if exist coordinate transform function in using VBnet
Post by: www1970 on July 27, 2006, 08:15:54 PM
ok! thanks!