How to check if 2 transformation are same?

My attempt …

    # Build a hash of transformation properties.
    # @param t [Geom::Transformation]
    # @return [Hash] 
    def transform_properties(t)
      vecX = X_AXIS.transform(t)
      vecY = Y_AXIS.transform(t)
      vecZ = Z_AXIS.transform(t)
      Hash[
        :origin, t.origin, # Geom::Point3d
        :xaxis,  t.xaxis,  # Geom::Vector3d (normalized)
        :yaxis,  t.yaxis,  # Geom::Vector3d (normalized)
        :zaxis,  t.zaxis,  # Geom::Vector3d (normalized)
        :xscale, (vecX.length*vecX.normalize.x).to_l, # Length
        :yscale, (vecY.length*vecY.normalize.y).to_l, # Length
        :zscale, (vecZ.length*vecZ.normalize.z).to_l, # Length
      ]
    end
    # Compare two hashes of transformation properties.
    # Hash#== will use each value's class #== method (in
    # addition to comparing keys and number of members.)
    # @param t1 [Geom::Transformation]
    # @param t2 [Geom::Transformation]
    # @return [Boolean]
    def transforms_equal?(t1,t2)
      transform_properties(t1) == transform_properties(t2)
    end
2 Likes