pymel.core.modeling.angleBetween

angleBetween(*args, **kwargs)

Returns the axis and angle required to rotate one vector onto another. If the construction history (ch) flag is ON, then the name of the new dependency node is returned.

Flags:
Long name (short name) Argument Types Properties
caching (cch) bool  
   
constructionHistory (ch) bool ../../../_images/create.gif
 

Turn construction history on or off. If true, a dependency node will be created and its name is returned.Default:falseFlag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

euler (er) bool ../../../_images/create.gif
 
return the rotation as 3 Euler angles instead of axis + angle
name (n) unicode  
   
nodeState (nds) int  
   
vector1 (v1) float, float, float ../../../_images/create.gif
 
vector to compute the rotation from
vector1X (v1x) float  
   
vector1Y (v1y) float  
   
vector1Z (v1z) float  
   
vector2 (v2) float, float, float ../../../_images/create.gif
 
vector to compute the rotation to
vector2X (v2x) float  
   
vector2Y (v2y) float  
   
vector2Z (v2z) float  
   

Derived from mel command maya.cmds.angleBetween

Example:

import pymel.core as pm

# To find the euler angle between these two vectors. The result is three
# angles in the current angular unit. In this example, the first vector
# must be rotated -63.434949 degrees about the X axis, 16.60155 degrees
# about the Y axis and -26.565051 degrees about the Z axis to achieve
# the second vector.

pm.angleBetween( euler=True, v1=(0.0, 1.0, 2.0), v2=(1.0, 2.0, 0.0) )
# Result: [-63.43494882292202, 16.601549599020235, -26.565051177077994] #

# To find the angle between these two vectors.  The result is an axis and
# an angle (in the current angular unit).  In this example, the first
# vector must be rotated 66.421822 degrees about the axis
# (-0.8728716, 0.4364358, -0.2182179) to achieve the second vector.

pm.angleBetween( v1=(0.0, 1.0, 2.0), v2=(1.0, 2.0, 0.0) )
# Result: [-0.8728715609439698, 0.4364357804719849, -0.21821789023599245, 66.42182152179817] #

# How to create a dependency node that calculates the angle between two
# vectors. This example shows how the (x,z) position of a sphere
# can be used to control the rotate factors (about y) of a cone shape.

angleBtwnNode = pm.angleBetween(v1=(1, 0, 0), v2=(1, 0, 0), ch=True)
sphere = pm.sphere()
pm.move( 5, 0, 5, sphere[0] )
pm.connectAttr( sphere[0]+'.translateX', angleBtwnNode+'.vector2X' )
pm.connectAttr( sphere[0]+'.translateZ', angleBtwnNode+'.vector2Z' )

cone = pm.cone( ch=False )
convert = pm.createNode( 'unitConversion' )
pm.connectAttr( angleBtwnNode+'.eulerY', convert+'.input' )
pm.connectAttr( convert+'.output', cone[0]+'.rotateY' )

Previous topic

pymel.core.modeling.alignSurface

Next topic

pymel.core.modeling.applyMetadata

Core

Core Modules

Other Modules

This Page