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
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.
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); }
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