Click here to Skip to main content
15,891,951 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: activex control not working in a dll Pin
nutkase21-Jan-07 23:06
nutkase21-Jan-07 23:06 
QuestionRotation Pin
Waldermort21-Jan-07 21:45
Waldermort21-Jan-07 21:45 
AnswerRe: Rotation Pin
softwaremonkey21-Jan-07 21:54
softwaremonkey21-Jan-07 21:54 
GeneralRe: Rotation Pin
nutkase21-Jan-07 23:11
nutkase21-Jan-07 23:11 
GeneralRe: Rotation Pin
Waldermort21-Jan-07 23:34
Waldermort21-Jan-07 23:34 
GeneralRe: Rotation Pin
nutkase22-Jan-07 1:15
nutkase22-Jan-07 1:15 
GeneralRe: Rotation Pin
softwaremonkey21-Jan-07 23:48
softwaremonkey21-Jan-07 23:48 
GeneralRe: Rotation Pin
Waldermort22-Jan-07 1:24
Waldermort22-Jan-07 1:24 
softwaremonkey wrote:
only suitable if you can live with integer angle values (every degree)


Thats no problem in this instance.

The major problem I am having at the moment is when placing the rotation code inside a loop, where the point being rotated is constantly being refreshed.

Here is a slightly faster method I have tried to adapt.
FPOINT Rotate( float px, float py, float ox, float oy, int a )
{
    //////////////////////////////////////////////////////////////////////////
    // Rotate point 'p' about point 'o' given 'a' degrees
    //////////////////////////////////////////////////////////////////////////

    float s = ( PI * a ) / 180;  // radians

    FPOINT q = { px, py };

    if ( px == ox && py == oy ) {
        return q;
    }

    float r;

    if ( px == ox ) {
        if ( py > oy ) {
            r = PI / 2;
        } else {
            r = - PI / 2;
        }
    } else {
        if ( py == oy ) {
            if ( px < ox ) {
                r = PI;
            } else {
                r = 0;
            }
        } else { // finally the general case
            if ( px < ox ) {
                r = atan( (float)( py - oy ) / ( px - ox ) ) + PI;
            } else {
                r = atan( (float)( py - oy ) / ( px - ox ) );
            }
        }
    }

    float hyp = sqrt( (float)( (px - ox) * (px - ox) ) + ( ( py - oy ) * ( py - oy ) ) );
    q.x = ( ox + cos(s+r) * hyp );
    q.y = ( oy + sin(s+r) * hyp );

    return q;
}


It's faster, but doesn't work correctly. I have 4 points denoted by the corners of a rectangle. I calc the center of the mass and pass it is as point 'o', then for each of the 4 points 'p' A calc their new positions. The resulting rectangle appears to rotate about the top-right corner ( which itself is traveling up and down a 45 degree line ). I can't for the life of me see where it is going wrong.
AnswerRe: Rotation Pin
Waldermort22-Jan-07 1:40
Waldermort22-Jan-07 1:40 
Questionlib file Pin
mike dano21-Jan-07 21:42
mike dano21-Jan-07 21:42 
AnswerRe: lib file Pin
Nibu babu thomas21-Jan-07 21:58
Nibu babu thomas21-Jan-07 21:58 
QuestionMutexes and sleeping threads Pin
softwaremonkey21-Jan-07 21:00
softwaremonkey21-Jan-07 21:00 
AnswerRe: Mutexes and sleeping threads Pin
Nibu babu thomas21-Jan-07 21:10
Nibu babu thomas21-Jan-07 21:10 
Questionhash_map in VC6 [modified] Pin
whatever@whatever.com21-Jan-07 20:22
whatever@whatever.com21-Jan-07 20:22 
AnswerRe: in VC6 Pin
Cedric Moonen21-Jan-07 20:24
Cedric Moonen21-Jan-07 20:24 
GeneralRe: in VC6 Pin
whatever@whatever.com21-Jan-07 20:47
whatever@whatever.com21-Jan-07 20:47 
GeneralRe: in VC6 Pin
Christian Graus21-Jan-07 23:43
protectorChristian Graus21-Jan-07 23:43 
QuestionHow to convert doc files to pdf files? Pin
asenthil_858521-Jan-07 20:00
asenthil_858521-Jan-07 20:00 
AnswerRe: How to convert doc files to pdf files? Pin
nutkase21-Jan-07 23:15
nutkase21-Jan-07 23:15 
AnswerRe: How to convert doc files to pdf files? Pin
David Crow22-Jan-07 4:54
David Crow22-Jan-07 4:54 
GeneralRe: How to convert doc files to pdf files? [modified] Pin
asenthil_858522-Jan-07 17:51
asenthil_858522-Jan-07 17:51 
QuestionSDI v/s dialog-based Pin
namratab21-Jan-07 19:05
namratab21-Jan-07 19:05 
AnswerRe: SDI v/s dialog-based Pin
Christian Graus21-Jan-07 23:44
protectorChristian Graus21-Jan-07 23:44 
GeneralRe: SDI v/s dialog-based Pin
namratab22-Jan-07 2:00
namratab22-Jan-07 2:00 
AnswerRe: SDI v/s dialog-based Pin
David Crow22-Jan-07 4:56
David Crow22-Jan-07 4:56 

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.