.NET

Reply
Contributor
12 Posts
0 Kudos
Registered: ‎09-23-2011
Post 1 of 6

UCS 3points

276 Views, 5 Replies
10-30-2012 05:26 AM

Hi,

 

I'm trying to place a UCS based on 3 points

- the origin of the UCS (PTOrigin)

- the x-direction (PTX)

- the y-direction (PTY)

 

The thing is that the angle between the vectorX (from origin to PTX) and vectorY (from origin to PTY) is not always 90°. Currently a create a new UCS in the UCSTable change the origin of the record to PTOrigin. Then I create a 3D vector from PTOrigin to PTX and then I'm stuck. I 'm unable to create a vector perpendicular to the vectorX which goes through PTY

 

Can anyone help me creating the Y-vector or are there other solutions for this?

 

thanks

 

Filip

ADN Support Specialist
761 Posts
100 Kudos
Registered: ‎03-21-2011
Post 2 of 6

Re: UCS 3points

11-04-2012 09:58 PM in reply to: f.roels

Hi Filip,

 

Have you tried rotating the PTX about the PTOrigin by 90 degrees to determine the PTY ?

 

or)

 

the other option is to first create a vector from PTX to PTOrigin and then use the "Vector3d.GetPerpendicularVector" method using that vector.



Balaji
Developer Technical Services
Autodesk Developer Network

*Expert Elite*
2,140 Posts
253 Kudos
Registered: ‎04-29-2006
Post 3 of 6

Re: UCS 3points

11-04-2012 11:28 PM in reply to: Balaji_Ram

Hi,

 

you can use the cross product of X axis  and Y axis to define the Z axis, then recalculate Y axis with the cross product of z axis and X axis.

 

Here's a quick and dirty (no error handling if points are overlapped or if xaxis is parallel to Y axis)

 

        private CoordinateSystem3d UcsBy3points(Point3d org, Point3d ptX, Point3d ptY)
        {
            Vector3d xAxis = org.GetVectorTo(ptX).GetNormal();
            Vector3d zAxis = xAxis.CrossProduct(org.GetVectorTo(ptY)).GetNormal();
            Vector3d yAxis = zAxis.CrossProduct(xAxis).GetNormal();
            return new CoordinateSystem3d(org, xAxis, yAxis);
        }

 

Gilles Chanteau
Contributor
12 Posts
0 Kudos
Registered: ‎09-23-2011
Post 4 of 6

Re: UCS 3points

11-05-2012 12:33 AM in reply to: _gile

Hi,

 

I think the solution with "Vector3d.GetPerpendicularVector" seems easy, but I've tried it without the desired result. The UCS is not always correct because some times the Y-direction must point to the negative Z-direction (from World UCS)

 

your second solutions seems more like it. I will try it in a few days and report the result.

 

thanks in advance

 

best

 

Filip

 

 

*Expert Elite*
2,140 Posts
253 Kudos
Registered: ‎04-29-2006
Post 5 of 6

Re: UCS 3points

11-05-2012 12:45 AM in reply to: f.roels

The way I purposed will also work whatever the new XY plane (i.e. 3D UCS rotated on X and/or Y axis).

Gilles Chanteau
Contributor
12 Posts
0 Kudos
Registered: ‎09-23-2011
Post 6 of 6

Re: UCS 3points

01-10-2013 03:54 AM in reply to: _gile

Hi Gilles

 

I was indeed incorrect. I tried your code again and it works fine now.

 

Thx

 

Filip

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post