CGTalk > Techniques > Character Rigging
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-17-2013, 06:38 AM   #1
Tawashi
New Member
portfolio
Masanori Tsutsumi
Tokyo, Japan
 
Join Date: Jun 2009
Posts: 1
Calculate angle from vector.

Hi,I'm trying to calculate angle from vector. It seems simple.

my test code is here:
Code:
proc test(){ vector $a = <<0, 1, 0>>; vector $b = <<0.5, 0.5, 0>>; float $c = $a * $b; float $mag_a = mag($a); float $mag_b = mag($b); float $theta = ($a*$b)/($mag_a * $mag_b); $theta = $theta * 180 / 3.14; print ("theta = " + $theta + "\n"); }test;


[result]
theta = 40.53478363

I think it`s 45.0 in mathematically,but The result ange is uncorrect.
It`s nearly 45.0 .
Is there are any items missing? or formula is uncorrect?

Please give me advice.

Sorry for my poor English.
 
Old 05-27-2013, 01:52 PM   #2
hazmondo
Expert
 
hazmondo's Avatar
portfolio
Harry
Rigging TD
Axis Animation
Glasgow, United Kingdom
 
Join Date: Jan 2013
Posts: 329
Hello,

It seems like your saying that θ = (a*b)/(|a|*|b|) but that equation is incorrect, the correct equation is cosθ = (a*b)/(|a|*|b|) --> θ = arccos((a*b)/(|a|*|b|)).

Hope this helps,
-Harry

Last edited by hazmondo : 05-27-2013 at 07:00 PM.
 
Old 06-15-2013, 02:14 PM   #3
ogbonna
Veteran
portfolio
Nathaniel Anozie
Baltimore, USA
 
Join Date: Dec 2008
Posts: 70
Hi, if using Maya might want to checkout the built-in angleBetween Node or MEL/Python command. Hope this is helpful.

Cheers!
-Nate
 
Old 06-21-2013, 10:40 PM   #4
DangerAhead
Rigger Lover
 
DangerAhead's Avatar
portfolio
Geordie Martinez
Character TD - Rigger - Massive TD
Industrial Light & Magic
San Francisco, USA
 
Join Date: Jun 2003
Posts: 437
PyMEL could really clear this up in a quick way. here is what you were doing. it was indeed 45 degrees:

Code:
import pymel.core as pm # make vectors vec1= pm.dt.Vector(0,1,0) vec2= pm.dt.Vector(0.5,0.5,0.0) # get angle between in radians radians = vec1.angle(vec2) #get degrees degrees = pm.dt.degrees(radians)
__________________
animrig.com
Check out my "Intro to PyMEL Training Video" at cgcircuit.com -- maya python the OOP way!
 
Old 06-21-2013, 10:40 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:04 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.