i'm scripting in python starters. making example simple, have 1 edge, uv coordinates of ([0,0],[1,1]), 45 degree angle. have edge ([0,0],[0,1]) angle 0/360 degrees. goal compare angles of 2 edges in order difference can modify angle of second edge match angle of first edge. there way via vector math?
easiest reconstruct , constructively remember imo complex picture. compute angle a=a.x+i*a.y b=b.x+i*b.y rotate b multiplying conjugate of a angle 0 angle resp. positive real axis,
arg((a.x-i*a.y)*(b.x+i*b.y)) =arg((a.x*b.x+a.y*b.y)+i*(a.x*b.y-a.y*b.x)) =atan2( a.x*b.y-a.y*b.x , a.x*b.x+a.y*b.y ) note screen coordinates use opposite orientation cartesian/complex plane, change use sign switch atan2(y,x) atan2(-y,x) angle in usual direction.
to produce vector b rotated angle (in radians) w a, multiply cos(w)+i*sin(w) obtain
b.x = cos(w)*a.x - sin(w)*a.y b.y = cos(w)*a.y + sin(w)*a.x you have rescale specified length of b.
Comments
Post a Comment