如何计算具有给定中心,角度和半径的点? [英] How to calculate a point with an given center, angle and radius?

查看:240
本文介绍了如何计算具有给定中心,角度和半径的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个SO问题中,有人要求计算三个角度点。我需要做相反的事情。

In this SO question, someone asked for calculating an angle from three points. I need to do the opposite thing.

我想画一个时钟,我有微小的刻度图像。一个艺术家做了60个,每个都有一个个人和准确的阴影。因此,有60个不同的图像,在10×10点的大小,已经正确旋转在该正方形的中心。

I want to draw a clock, and I have tiny tick images. An art dude made 60 of them, each with an individual and accurate shadow. So there are 60 distinct images at 10x10 points in size, already correctly rotated in the center of that square.

所以每6度一刻图像必须放置。我只需要根据中心点,半径和角度计算x / y坐标。

So every 6 degrees one tick image has to be placed. I would just need to calculate the x/y coordinate based on a center point, an radius and an angle.

所以我有:


  • 中心点

  • 半径

  • 角度

有一个简单的方法来计算x / y坐标?也许可可触摸已经有一个有用的功能或方法为此?

Is there an easy way to calculate the x/y coordinate with this? Maybe cocoa-touch already has a useful function or method for this?

推荐答案

a 角度,(x,y)中心点和 r 半径,那么你的点将在

let a be the angle, (x,y) the center point and r the radius, then your point will be at

(x + r*sin(a), y + r*cos(a))

这篇关于如何计算具有给定中心,角度和半径的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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