Click here to Skip to main content
15,887,027 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Polyline offset algorithm Pin
cp987617-Jun-08 12:10
cp987617-Jun-08 12:10 
AnswerRe: Polyline offset algorithm Pin
Arash Partow18-Jun-08 1:22
Arash Partow18-Jun-08 1:22 
GeneralRe: Polyline offset algorithm Pin
beko18-Jun-08 19:55
beko18-Jun-08 19:55 
QuestionWhat's the period of (cos ax)(sin bx)? Pin
sherifffruitfly14-Jun-08 10:00
sherifffruitfly14-Jun-08 10:00 
AnswerRe: What's the period of (cos ax)(sin bx)? Pin
cp987614-Jun-08 19:03
cp987614-Jun-08 19:03 
AnswerRe: What's the period of (cos ax)(sin bx)? Pin
MarkB77715-Jun-08 2:00
MarkB77715-Jun-08 2:00 
AnswerRe: What's the period of (cos ax)(sin bx)? Pin
CPallini15-Jun-08 22:02
mveCPallini15-Jun-08 22:02 
QuestionQuaternion to Euler Pin
Xmen Real 11-Jun-08 3:08
professional Xmen Real 11-Jun-08 3:08 
im trying to convert Quaternion to Euler but i dont have appropriate code, i searched on lots of sites but their converting code do not match with converting back, mean, if i convert from Quaternion to Euler then i convert back the result value to Quaternion, i got different output, here is my code

public static float[] ToEuler(double tmp_x, double tmp_y, double tmp_z,double tmp_w)
{
    float[] Euler = new float[3];
    double sqr_X = tmp_x * tmp_x;
    double sqr_Y = tmp_y * tmp_y;
    double sqr_Z = tmp_z * tmp_z;
    double sqr_W = tmp_w * tmp_w;

    const double radian = 180 / Math.PI;
    double check = tmp_x * tmp_y + tmp_z * tmp_w;
    double unit = sqr_X + sqr_Y + sqr_Z + sqr_W;
    if (check > 0.499 * unit)
    {
        Euler[0] = 0;
        Euler[1] = (float)(radian * Math.Atan2(tmp_x, tmp_w));
        Euler[2] = (float)90;
        return Euler;
    }
    else if (check < -0.499 * unit)
    {
        Euler[0] = 0;
        Euler[1] = (float)(-radian * Math.Atan2(tmp_x, tmp_w));
        Euler[2] = (float)-90;
        return Euler;
    }

    Euler[0] = (float)(radian * (Math.Atan2(2 * (tmp_x * tmp_w + tmp_y * tmp_z), (-sqr_X - sqr_Y + sqr_Z + sqr_W))));
    Euler[1] = (float)(radian * (Math.Asin(-2 * (tmp_x * tmp_z - tmp_y * tmp_w))));
    Euler[2] = (float)(radian * (Math.Atan2(2.0 * (tmp_x * tmp_y + tmp_z * tmp_w), (sqr_X - sqr_Y - sqr_Z + sqr_W))));
    return Euler;
}

public static float[] ToEulerA(double x, double y, double z, double w)
{
    //double w = Convert.ToDouble(br.ReadSingle());
    //double x = Convert.ToDouble(br.ReadSingle());
    //double y = Convert.ToDouble(br.ReadSingle());
    //double z = Convert.ToDouble(br.ReadSingle());
    double sqw = w * w;
    double sqx = x * x;
    double sqy = y * y;
    double sqz = z * z;
    double unit = sqx + sqy + sqz + sqw;
    double test = x * y + z * w;
    double RX = 0;
    double RY = 0;
    double RZ = 0;

    if (test > 0.499 * unit)
    {
        RX = 2 * Math.Atan2(x, w);
        RY = Math.PI / 2;
        RZ = 0;
    }
    else if (test < -0.499 * unit)
    {
        RX = -2 * Math.Atan2(x, w);
        RY = -Math.PI / 2;
        RZ = 0;
    }
    else
    {
    RX = Math.Atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw);
    RY = Math.Asin(2 * test / unit);
    RZ = Math.Atan2(2 * x * w - 2 * y * z, -sqx + sqy - sqz + sqw);
    }
    RX = 180 / Math.PI * RX;
    RY = 180 / Math.PI * RY;
    RZ = 180 / Math.PI * RZ;
    return new float[] { (float)RX, (float)RY, (float)RZ };
}


im not sure which one is correct or both are incorrect...
any idea to solve this ?
thanks

TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can

AnswerRe: Quaternion to Euler Pin
cmk11-Jun-08 11:27
cmk11-Jun-08 11:27 
GeneralRe: Quaternion to Euler Pin
Xmen Real 11-Jun-08 12:48
professional Xmen Real 11-Jun-08 12:48 
AnswerRe: Quaternion to Euler Pin
Mark Churchill12-Jun-08 18:38
Mark Churchill12-Jun-08 18:38 
QuestionGraphical Object drawing algorithms Pin
Monty29-Jun-08 2:59
Monty29-Jun-08 2:59 
AnswerRe: Graphical Object drawing algorithms Pin
73Zeppelin9-Jun-08 3:11
73Zeppelin9-Jun-08 3:11 
GeneralRe: Graphical Object drawing algorithms Pin
Monty29-Jun-08 3:24
Monty29-Jun-08 3:24 
GeneralRe: Graphical Object drawing algorithms Pin
73Zeppelin9-Jun-08 3:37
73Zeppelin9-Jun-08 3:37 
GeneralRe: Graphical Object drawing algorithms Pin
Tim Craig9-Jun-08 17:37
Tim Craig9-Jun-08 17:37 
GeneralRe: Graphical Object drawing algorithms Pin
Monty29-Jun-08 21:02
Monty29-Jun-08 21:02 
GeneralRe: Graphical Object drawing algorithms Pin
Tim Craig9-Jun-08 21:15
Tim Craig9-Jun-08 21:15 
GeneralRe: Graphical Object drawing algorithms Pin
Monty29-Jun-08 22:17
Monty29-Jun-08 22:17 
QuestionWhat's the most popular algorithm for video compression in industry? Pin
followait7-Jun-08 16:55
followait7-Jun-08 16:55 
AnswerRe: What's the most popular algorithm for video compression in industry? Pin
73Zeppelin8-Jun-08 8:47
73Zeppelin8-Jun-08 8:47 
AnswerRe: What's the most popular algorithm for video compression in industry? Pin
Tolga Birdal25-Oct-08 7:06
Tolga Birdal25-Oct-08 7:06 
QuestionBest Fit Algo. Pin
deezZ6-Jun-08 19:06
deezZ6-Jun-08 19:06 
AnswerRe: Best Fit Algo. Pin
73Zeppelin8-Jun-08 8:42
73Zeppelin8-Jun-08 8:42 
AnswerRe: Best Fit Algo. Pin
cp98768-Jun-08 11:45
cp98768-Jun-08 11:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.