.NET

Reply
Contributor
f.roels
Posts: 12
Registered: ‎09-23-2011
Message 1 of 6 (262 Views)

UCS 3points

262 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
Balaji_Ram
Posts: 701
Registered: ‎03-21-2011
Message 2 of 6 (223 Views)

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*
_gile
Posts: 2,084
Registered: ‎04-29-2006
Message 3 of 6 (217 Views)

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
f.roels
Posts: 12
Registered: ‎09-23-2011
Message 4 of 6 (210 Views)

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*
_gile
Posts: 2,084
Registered: ‎04-29-2006
Message 5 of 6 (204 Views)

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
f.roels
Posts: 12
Registered: ‎09-23-2011
Message 6 of 6 (149 Views)

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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.