.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UCS 3points

5 REPLIES 5
Reply
Message 1 of 6
f.roels
509 Views, 5 Replies

UCS 3points

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

5 REPLIES 5
Message 2 of 6
Balaji_Ram
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

Message 3 of 6
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 6
f.roels
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

 

 

Message 5 of 6
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 6
f.roels
in reply to: _gile

Hi Gilles

 

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

 

Thx

 

Filip

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost