Transforming point coordinates

Transforming point coordinates

MGO-Norsyn
Advocate Advocate
9,963 Views
4 Replies
Message 1 of 5

Transforming point coordinates

MGO-Norsyn
Advocate
Advocate

 

Hi all

 

I would like to ask for advice regarding coordinate transformation in the API.

 

I've got a number of points (Detail Item's location coordinates) in global systems which I want to describe in a particular family's coordinate system O', see attached picture. O is global origin, O' is the target Detail Item's location coordinates, big crosses are other Detail Item's location coordinates which need to be described in X',Y'.

TransformCoordinates.png

 

 

As far as I understand I need to get the transform from the detail item family located at O' something like this:

Transform trf = O'.Location.GetTransform()

And then apply trf to each point that needs transforming to the new coordinate system. After this, X, Y, Z values returned from the transformed location points will be in the O' coordinate system.

 

Is this correct?

0 Likes
Accepted solutions (1)
9,964 Views
4 Replies
Replies (4)
Message 2 of 5

MGO-Norsyn
Advocate
Advocate

Do I have to do something like this: where transform is of the O' family and point is the Location as LocationPoint for points which I need to transform

 

public static XYZ TransformPoint(XYZ point, Transform transform)
{
    double x = point.X;
    double y = point.Y;
    double z = point.Z;

    //transform basis of the old coordinate system in the new coordinate // system
    XYZ b0 = transform.get_Basis(0);
    XYZ b1 = transform.get_Basis(1);
    XYZ b2 = transform.get_Basis(2);
    XYZ origin = transform.Origin;

    //transform the origin of the old coordinate system in the new 
    //coordinate system
    double xTemp = x * b0.X + y * b1.X + z * b2.X + origin.X;
    double yTemp = x * b0.Y + y * b1.Y + z * b2.Y + origin.Y;
    double zTemp = x * b0.Z + y * b1.Z + z * b2.Z + origin.Z;

    return new XYZ(xTemp, yTemp, zTemp);
}
0 Likes
Message 3 of 5

MGO-Norsyn
Advocate
Advocate
Accepted solution

The initial thought was correct.

 

To describe a series of points in a family's local coordinate system following must be done:

 

Transform trf = FamilyInOrigoOfNewCoordinateSystem.GetTransform();
trf = trf.Inverse;

Get the transform of the family in origo' and inverse it.

XYZ tPoint = trf.OfPoint(point);

Apply the transform to the points which need to be described. After that X, Y, Z properties of these points return values set in the local system of the family where the transform was obtained (Origo in the first code block).

Message 4 of 5

olena_havatiuk
Explorer
Explorer

 thanks,

Message 5 of 5

andreyzr43
Participant
Participant

Tell me how to return the coordinate system of the project for the point?

0 Likes