Author Topic: if exist coordinate transform function in using VBnet  (Read 5501 times)

0 Members and 1 Guest are viewing this topic.

www1970

  • Guest
if exist coordinate transform function in using VBnet
« 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

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: if exist coordinate transform function in using VBnet
« Reply #1 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?

"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: if exist coordinate transform function in using VBnet
« Reply #2 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
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: if exist coordinate transform function in using VBnet
« Reply #3 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?
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: if exist coordinate transform function in using VBnet
« Reply #4 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 >
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: if exist coordinate transform function in using VBnet
« Reply #5 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.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: if exist coordinate transform function in using VBnet
« Reply #6 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 ..

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

www1970

  • Guest
Re: if exist coordinate transform function in using VBnet
« Reply #7 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" ?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: if exist coordinate transform function in using VBnet
« Reply #8 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 ..! :-)
« Last Edit: July 27, 2006, 06:03:17 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: if exist coordinate transform function in using VBnet
« Reply #9 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.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

www1970

  • Guest
Re: if exist coordinate transform function in using VBnet
« Reply #10 on: July 27, 2006, 08:15:54 PM »
ok! thanks!