xBimTeam / XbimEssentials

A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
https://xbimteam.github.io/
Other
485 stars 172 forks source link

Rotation in IfcAxis2Placement3D #479

Closed OzKitsune closed 1 year ago

OzKitsune commented 1 year ago

Hello!

Please help me figure out how to set the rotation of an object when creating of IFC.

I have a rotation given by a quaternion and I am using this code from the example:

parent.ObjectPlacement = i.New<IfcLocalPlacement>(p => p.RelativePlacement = i.New<IfcAxis2Placement3D>(a =>
{
    a.Location = i.New<IfcCartesianPoint>(cp => cp.SetXYZ(0, 0, 0));
    a.RefDirection = i.New<IfcDirection>();
    a.RefDirection.SetXYZ(1, 0, 0);
    a.Axis = i.New<IfcDirection>();
    a.Axis.SetXYZ(0, 0, 1);
}));

As I understood, I need to set the value in RefDirection, but I do not understand how exactly this should be done.

martin1cerny commented 1 year ago

You need to use quaternion to compute directions of the X (RefDirection) and Z (Axis) axes. These define the local coordination system.

OzKitsune commented 1 year ago

Thanks for help, I think I figured it out.