Post date: Jul 25, 2016 8:29:55 AM
基本的には2つのベクトルを正規化し,内積または外積を求める.
内積:ax*bx+ay*by cos
外積:ax*by-ay*bx sin
void setup(){ size(400,400); } void draw(){ background(255); line(width/2,height/2,width/2,height); line(width/2,height/2,mouseX,mouseY); PVector a=new PVector(0,-height/2); PVector b=new PVector(mouseX-width/2,mouseY-height/2); a.normalize(); b.normalize(); println(((a.x*b.y-a.y*b.x>0)?"左":"右")+"に"+degrees(max(min(acos(a.dot(b)),1),-1))+"度"); }