TheSwamp
Code Red => .NET => Topic started 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
-
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?
-
Close Mick,
the polar function takes 3 arguments
From_Point
Rotation_angle
Distance_along_angle_path
returns the calculated point, in the current UCS
-
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?
-
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 >
-
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.
-
Something like ..
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 ..
-
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" ?
-
"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 ..! :-)
-
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.
-
ok! thanks!