Contents

조회 수 10832 댓글 0
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
극 좌표계의 좌표인 거리와 각도를 입력 받아서
직각 좌표계의 좌표 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;
}



?

  1. [c] 거리와 각도를 입력받아서 좌표로 변환

    Date2013.04.23 CategoryDevelop Byhooni Views10832
    Read More
  2. [c++] 윈도우 API 정복 예제

    Date2013.04.23 CategoryDevelop Byhooni Views7633
    Read More
  3. OpenGL 강좌 사이트 모음

    Date2013.04.23 CategoryDevelop Byhooni Views9668
    Read More
  4. [c] 공용체를 이용해 MSB를 LSB로 변환

    Date2013.04.23 CategoryDevelop Byhooni Views9388
    Read More
  5. [c] 함수 목록과 예제 소스 파일

    Date2013.04.23 CategoryDevelop Byhooni Views7206
    Read More
  6. [c] 윈도우 API Viewport와 Window

    Date2013.04.23 CategoryDevelop Byhooni Views5977
    Read More
  7. [c] 윈도우 API sin 함수 출력..

    Date2013.04.23 CategoryDevelop Byhooni Views15683
    Read More
  8. 베지어 곡선(Bézier curve) 알고리즘(spline 곡선)

    Date2013.04.23 CategoryDevelop Byhooni Views33406
    Read More
  9. [c] 압축 알고리즘 소스 및 정리

    Date2013.04.23 CategoryDevelop Byhooni Views8789
    Read More
  10. [c] 구구단 최단라인 ㅡㅡ;

    Date2013.04.23 CategoryDevelop Byhooni Views8071
    Read More
  11. [c++] 초간단 스택 두 가지 방식(class, struct)

    Date2013.04.23 CategoryDevelop Byhooni Views7625
    Read More
  12. [c][java] 주사선 채우기 알고리즘(scan line filling algorithm) 구현

    Date2013.04.23 CategoryDevelop Byhooni Views8979
    Read More
Board Pagination Prev 1 ... 19 20 21 22 23 24 25 26 27 28 ... 71 Next
/ 71