diff --git a/src/blenderbim/blenderbim/bim/module/georeference/operator.py b/src/blenderbim/blenderbim/bim/module/georeference/operator.py index c8ec61e865..c5e1e93b51 100644 --- a/src/blenderbim/blenderbim/bim/module/georeference/operator.py +++ b/src/blenderbim/blenderbim/bim/module/georeference/operator.py @@ -145,7 +145,7 @@ class SetNorthOffset(bpy.types.Operator): def execute(self, context): context.scene.sun_pos_properties.north_offset = -radians( - ifcopenshell.util.geolocation.xy2angle( + ifcopenshell.util.geolocation.xaxis2angle( context.scene.BIMGeoreferenceProperties.map_conversion.get("XAxisAbscissa").float_value, context.scene.BIMGeoreferenceProperties.map_conversion.get("XAxisOrdinate").float_value, ) diff --git a/src/ifcopenshell-python/ifcopenshell/util/geolocation.py b/src/ifcopenshell-python/ifcopenshell/util/geolocation.py index a3f5d1722d..b3f3b568c6 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/geolocation.py +++ b/src/ifcopenshell-python/ifcopenshell/util/geolocation.py @@ -94,6 +94,16 @@ def global2local(matrix, eastings, northings, orthogonal_height, x_axis_abscissa ) -# Used for converting the X and Y vectors of the X Axis in IFC geolocation -def xy2angle(x, y): +# Used for converting the X and Y vectors of the X Axis in IFC grid north geolocation +def xaxis2angle(x, y): return math.degrees(math.atan2(y, x)) + + +# Used for converting the X and Y vectors of the Y Axis in IFC true north geolocation +def yaxis2angle(x, y): + angle = math.degrees(math.atan2(y, x)) - 90 + if angle < -180: + angle += 360 + elif angle > 180: + angle -= 360 + return angle