I want to know the Angle between a face and the X-axis, as shown in the figure below,I’m going to rotate the face 30 degrees counterclockwise, which is easier to calculate when it’s a rectangle, but what good way to calculate when a face is irregular.
I get a method from someone else, using the normal vector to calculate the Angle between a plane and the X-axis, Y-axis, and z-axis, but I don’t know how to get the θ,this is the code:
model = Sketchup.active_model
entities = model.active_entities
selection = model.selection
face = selection[0]
vector_face_norm = face.normal
angle_to_x = vector_face_norm.angle_between X_AXIS
angle_to_x_deg = angle_to_x.radians
angle_to_y = vector_face_norm.angle_between Y_AXIS
angle_to_y_deg = angle_to_y.radians
angle_to_z = vector_face_norm.angle_between Z_AXIS
angle_to_z_deg = angle_to_z.radians
puts "Face normal angle to X axis: #{angle_to_x} rad, #{angle_to_x_deg}°"
puts "Face normal angle to Y axis: #{angle_to_y} rad, #{angle_to_y_deg}°"
puts "Face normal angle to Z axis: #{angle_to_z} rad, #{angle_to_z_deg}°"