如何使用其他两个点及其角度找到第三个点 [英] How to find a third point using two other points and their angle

查看:105
本文介绍了如何使用其他两个点及其角度找到第三个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里找到了答案,但是不明白如何将数学转移到目标C

I found an answer here, but can't understand how to transfer the math to Objective C

找到第三个点

我有两个点,并且我也有相对于轴的角度。我如何找到将形成一条直线的第三点?距离应可变。

I have two points and I also have the angle relative to the axes. How do I find a third point which will form a straight line? The distance should be variable.

推荐答案

这是我正在使用的代码:

This is the code that I am using:

float distanceFromPx2toP3 = 1300.0;    

float mag = sqrt(pow((px2.x - px1.x),2) + pow((px2.y - px1.y),2));
float P3x = px2.x + distanceFromPx2toP3 * (px2.x - px1.x) / mag;
float P3y = px2.y + distanceFromPx2toP3 * (px2.y - px1.y) / mag;

CGPoint  P3 = CGPointMake(P3x, P3y);

这篇关于如何使用其他两个点及其角度找到第三个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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