Created
January 6, 2015 22:45
-
-
Save jimfoltz/e7e7473067536b4c2991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/a/17982272/816093 | |
module TransformationHelper | |
def flipped_x? | |
dot_x, dot_y, dot_z = axes_dot_products() | |
dot_x < 0 && flipped?(dot_x, dot_y, dot_z) | |
end | |
def flipped_y? | |
dot_x, dot_y, dot_z = axes_dot_products() | |
dot_y < 0 && flipped?(dot_x, dot_y, dot_z) | |
end | |
def flipped_z? | |
dot_x, dot_y, dot_z = axes_dot_products() | |
dot_z < 0 && flipped?(dot_x, dot_y, dot_z) | |
end | |
private | |
def axes_dot_products | |
[ | |
xaxis.dot(X_AXIS), | |
yaxis.dot(Y_AXIS), | |
zaxis.dot(Z_AXIS) | |
] | |
end | |
def flipped?(dot_x, dot_y, dot_z) | |
dot_x * dot_y * dot_z < 0 | |
end | |
end | |
module Example | |
def self.inspect_flipped | |
tr = Sketchup.active_model.selection[0].transformation | |
tr.extend(TransformationHelper) | |
puts "X Flipped: #{tr.flipped_x?.inspect}" | |
puts "Y Flipped: #{tr.flipped_y?.inspect}" | |
puts "Z Flipped: #{tr.flipped_z?.inspect}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment