110,571
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] p1 = new int[3] { 100, 50, 20 };//原始点
int[] p2 = new int[3];//要求的点
double d = 30;//两点之间的距离
double pai = 3.1415926;//π,将角度转化成弧度制用;
Console.WriteLine("请输入角度");
int jiaodu = Convert.ToInt32(Console.ReadLine());//输入角度
double hudu = jiaodu * pai / 180;//将角度转化成弧度制
p2[0] = p1[0] + (int)(d * Math.Cos(hudu));//求X坐标
p2[1] = p1[1] + (int)(d * Math.Sin(hudu));//求Y坐标
p2[2] = p1[2];//Z坐标不变
//显示三个坐标值
foreach (int item in p2)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}
时间有限,取得π是近似值,有时间楼主可以优化下精确值。