(x,y)围绕某点(x0,y0)作旋转变换(X,Y)的计算公式:
X=x0+(x-x0)cos(θ)-(y-y0)sin(θ);
Y=y0+(x-x0)sin(θ)+(y-y0)cos(θ);我用这个工式怎么只能在二.四象限转啊.比如已知直线两点(x1,y1)(x2,y2) 和我要转到的位置点(x3, y3) 直线的中点(x0, y0)
变量DotToLine为(x3, y3)到直线的距离,DotToDot为(x3, y3)到中点的距离
asin(DotToLine / DotToDot)为θ
用上面的工式就是只在两个象限,如果是asin(-DotToLine / DotToDot)就是在另两个.
请问怎么解决啊.

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4816/4816278.xml?temp=.146496
      

  2.   

    θ角要计算为从X轴正向开始逆时针在0--360度范围里,而不是Asin的主值范围1、4象限;
    应该使用asin2函数来计算角度。
      

  3.   

    atan, atan2
    Calculates the arctangent of x (atan) or the arctangent of y/x (atan2).double atan( double x );double atan2( double y, double x );Routine Required Header Compatibility 
    atan <math.h> ANSI, Win 95, Win NT 
    atan2 <math.h> ANSI, Win 95, Win NT 
    For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version 
    LIBCMT.LIB Multithread static library, retail version 
    MSVCRT.LIB Import library for MSVCRT.DLL, retail version 
    Return Valueatan returns the arctangent of x. atan2 returns the arctangent of y/x. If x is 0, atan returns 0. If both parameters of atan2 are 0, the function returns 0. You can modify error handling by using the _matherr routine. atan returns a value in the range –π/2 to π/2 radians; atan2 returns a value in the range –π to π radians, using the signs of both parameters to determine the quadrant of the return value. Parametersx, yAny numbersResThe atan function calculates the arctangent of x. atan2 calculates the arctangent of y/x. atan2 is well defined for every point other than the origin, even if x equals 0 and y does not equal 0.Example/* ATAN.C: This program calculates 
     * the arctangent of 1 and -1.
     */#include <math.h>
    #include <stdio.h>
    #include <errno.h>void main( void ) 
    {
       double x1, x2, y;   printf( "Enter a real number: " );
       scanf( "%lf", &x1 );
       y = atan( x1 );
       printf( "Arctangent of %f: %f\n", x1, y );
       printf( "Enter a second real number: " );
       scanf( "%lf", &x2 );
       y = atan2( x1, x2 );
       printf( "Arctangent of %f / %f: %f\n", x1, x2, y ); 
    }
    OutputEnter a real number: -862.42
    Arctangent of -862.420000: -1.569637
    Enter a second real number: 78.5149
    Arctangent of -862.420000 / 78.514900: -1.480006
    Floating-Point Support RoutinesSee Also   acos, asin, cos, _matherr, sin, tan
      

  4.   

    asin的值域范围是(-90,90),还要再判断x3-x0的正负号,负的话再加180度。
      

  5.   

    现将(x0,y0)设为原点求(x,y)相对坐标(x',y')
    然后对(x',y')旋转,这样就简单多了,可以用旋转矩阵,旋转结束后在将结果(x'',y'')加上(x0,y0)得到最后结果,这样就没有象限问题了