Java Reference
In-Depth Information
if (returnposi>(slideposi[i]+slideposi[i+1])/2.0f)
{
returnposi = slideposi[i];
}
else
{
returnposi = slideposi[i+1];
}
}
}
return returnposi;
}
h.20 calculatInG mouse anGle relatIve to knob
//Returning the value of the current angle
private float CalAngle(Point3f part, Point3f component, Point3f CurrentPt)
{
float angle;
angle = (float)(Math.atan2(CurrentPt.x-component.x-part.x,
CurrentPt.y-component.y-part.y)/Math.PI);
angle = (-angle+1.0f)*PAI - PAI/2.0f;
if (angle<0.0f) angle = angle+2.0f*PAI; //The angle value is negative
return angle;
//Returning the angle value of 0 to 2*PAI
}
h.21 calculatInG chanGe In mouse anGle
//Returning the angle difference between the current angle and last one
private float DeltaAngle(float currentangle, float lastangle)
{
float delta;
if (currentangle-lastangle>2.0f)
{
// currentangle is in the 4th phase and lastangle is in the 1st phase
delta = currentangle - lastangle - 2.0f*PAI;
}
else if (currentangle-lastangle<-2.0f)
{
// currentangle is in the 1st phase and lastangle is in the 4th phase
delta = currentangle -lastangle + 2.0f*PAI;
}
else
{
delta = currentangle -lastangle;
}
return delta;
}
Search WWH ::




Custom Search