给定一个角度和长度,我怎么计算的坐标 [英] Given an angle and length, how do I calculate the coordinates

查看:1621
本文介绍了给定一个角度和长度,我怎么计算的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设左上角为(0,0),我给的30度角的(0,300)为出发点,为600线的长度,我该如何计算该行的终点所以
该行是重新指定的角度presentative。

的C伪code是

 的main(){
  INT X,Y;  getEndPoint(30,600,0,300,&放大器;的x,&放大器; y)基
  的printf(结束X =%D,最终Y =%d个,X,Y);
}//输入角度可以从0 - 90度无效getEndPoint(INT角度,诠释LEN,诠释start_x,诠释start_y,为int * end_x,为int * end_y)
{    这里计算的端点的角度和长度    * end_x = calculated_end_x;
    * end_y = calculated_end_y;
}


解决方案

  //编辑添加的转换
    的#define radian2degree(A)(A * 57.295779513082)
    的#define degree2radian(A)(A * 0.017453292519)        X = start_x + LEN * COS(角度);
        Y = start_y + len个*罪(角);

Assuming the upper left corner is (0,0) and I'm given an angle of 30 degrees, a starting point of (0,300), a line length of 600, how do I calculate the ending point of the line so that the line is representative of the angle given.

The C pseudo-code is

main() {
  int x,y;

  getEndPoint(30, 600, 0, 300, &x, &y);
  printf("end x=%d, end y=%d", x, y);
}

// input angle can be from 0 - 90 degrees

void getEndPoint(int angle, int len, int start_x, int start_y, int *end_x, int *end_y) 
{

    calculate the endpoint here for angle and length

    *end_x = calculated_end_x;
    *end_y = calculated_end_y;
}

解决方案

// edit to add conversion
    #define radian2degree(a) (a * 57.295779513082)
    #define degree2radian(a) (a * 0.017453292519)

        x = start_x + len * cos(angle);
        y = start_y + len * sin(angle);

这篇关于给定一个角度和长度,我怎么计算的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆