Getting angle relative to component
-
I'm using the following code to get the angle relative to the world axis and it works great but I'd also like to get the angle relative to the component which is selected when the cursor is inline with the component... like in the attachement where the angle read is 45 returned is 45 degrees I'd like it to be 0.0 degrees.
@rotation_point=Geom;;Point3d.new(@iptemp.position) ptx=Geom;;Point3d.new(@ip2.position) ptx=Geom;;Point3d.new([ptx.x, ptx.y, @rotation_point.z]) vector=@rotation_point.vector_to(ptx) crossvector=vector.cross(X_AXIS) multiplier=crossvector[2] if multiplier<0 multiplier=1 else multiplier=-1 end @angle=((X_AXIS.angle_between(vector)).radians)*multiplierI tried getting the component's angle and subtracting it from @angle but the results aren't very accurate for some reason. I also tried creating a new vector3d from the compoent instance's transformation and that gives me the same results
trans=parent_instance.transformation.to_a vector=Geom;;Vector3d.new(trans[0], trans[4], trans[8])
Any ideas?
EDIT: Found a solution
Actually had the solution all along but it was so simple I overlooked it...
subtracting the existing components angle from @angle does work... IF you do it in the right order!!
wrong...
existing_comp_angle-@angleright...
@angle-existing_comp_angle
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement