As a 'Thanks!' to Alex and my contribution to wellness of other exporters and especially their developers π here is my modified transformation method that works I think in 99.9%. It may fail due to float precision, but I looks it doesn't happen too often.
My idea is to calculate a center of the image, based on initially derived transformation and to compare it with a center of bounding box of the instance self.bounds.center. If the points are not same it means that an image is flipped.
If flipped, I create a modified transformation with a negative scaling along y axis.
Now I realized that this can be done by simply crating a Geom::Transformation.scaling origin, 1, -1, 1 and applying it to the original trans...
def transformation
origin = self.origin
axes = self.normal.axes
tr = Geom;;Transformation.axes(ORIGIN, axes.x, axes.y, axes.z)
tr = tr * Geom;;Transformation.rotation(ORIGIN, Z_AXIS, self.zrotation)
tr = tr * Geom;;Transformation.scaling(ORIGIN, self.width/self.pixelwidth, self.height/self.pixelheight,1)
tr=tr.to_a
tr[12]=origin.x
tr[13]=origin.y
tr[14]=origin.z
trans = Geom;;Transformation.new(tr) #Global! trans of an image instance
#check if flipped
center_point=Geom;;Point3d.new(self.pixelwidth/2.0,self.pixelheight/2.0,0).transform! trans #center of an image
center=self.bounds.center
flipped=(center_point.x!=center.x or center_point.y!=center.y or center_point.z!=center.z)
if flipped
tr = Geom;;Transformation.axes(ORIGIN, axes.x, axes.y, axes.z)
tr = tr * Geom;;Transformation.rotation(ORIGIN, Z_AXIS, self.zrotation)
tr = tr * Geom;;Transformation.scaling(ORIGIN, self.width/self.pixelwidth, -self.height/self.pixelheight,1)
tr=tr.to_a
tr[12]=origin.x
tr[13]=origin.y
tr[14]=origin.z
trans = Geom;;Transformation.new(tr)
end
return trans
end#def