Contents

Views 11454 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
극 좌표계의 좌표인 거리와 각도를 입력 받아서
직각 좌표계의 좌표 x, y 로 변환하는 프로그램

/*
*    극 좌표계의 좌표인 거리와 각도를 입력 받아서
*    직각 좌표계의 좌표 x, y 로 변환하는 프로그램
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define     PI    3.14159
#define     X     0
#define     Y     1 

float* get_coord_ad( float degree, float distance ){
    float* point = malloc( sizeof( float ) * 2 );

    degree = PI * degree / 180;
    point[X] = distance * cos( degree );
    point[Y] = distance * sin( degree );

    return point;
}

int main(){
    float dist, ang, *ptr_coord;

    printf( "Enter a distance : " );
    scanf( "%f", &dist );
    fflush( stdin );
    
    printf( "Enter a degree : " );
    scanf( "%f", &ang );
    fflush( stdin );
    
    ptr_coord = get_coord_ad( ang, dist );
    printf( "\n극 좌표(%-4.2f, %-4.2f)를 직각 좌표로 변환하면 (%-4.2f, %-4.2f)입니다.\n",
        dist, ang, ptr_coord[X], ptr_coord[Y] );

    free( ptr_coord );

    return 1;
}



?

List of Articles
No. Category Subject Author Date Views
567 Develop [c] 그래픽스 자료(OpenGL 라이브러리) 샘플 소스 file hooni 2003.04.23 11327
566 Develop [html] SVG(Scalable Vector Graphics) 간단 정리 hooni 2014.02.13 11325
565 Develop [java] Interface 와 abstract hooni 2013.04.23 11272
564 Develop [java] 입출력 스트림 2부 (바이트) file hooni 2013.04.23 11260
563 Develop [c] OpenGL 임시로 여기 올림.. hooni 2003.04.23 11173
562 Develop [c++] Window API(MFC) 오목 게임 file hooni 2003.04.23 11148
561 Develop [php] 니우쪽지다.. 받아라~ ^^ file hooni 2003.04.23 11145
560 Develop [js] 밀리터리 프로그램(전역일 계산) 7 file hooni 2013.04.23 11132
559 Develop [iphone] 파일 업로드 샘플 코드 ㅎㅎ secret hooni 2013.04.23 11120
558 Develop [c++] 퍼즐 버블버블 간단한 원리(사용공식) file hooni 2013.04.23 11096
557 Develop [js] jQuery 배열 루프(each) hooni 2013.12.17 11095
556 Develop [ios] In App Purchase 개발 hooni 2013.11.20 11063
Board Pagination Prev 1 ... 19 20 21 22 23 24 25 26 27 28 ... 71 Next
/ 71