如何计算两个给定点和给定距离之间的点? [英] How to calculate the points between two given points and given distance?
问题描述
我有 A(35.163,128.001)
和点 B(36.573,128.707)
我需要计算点在A点和B点之间使用2点之间的标准距离公式,我发现 D = 266.3
每个点位于AB线(黑点p1,p2,...) 。如何计算X的值?如何计算X的值?如何计算X的值?如何计算X和Y为p1,p2,... p8?
欢迎使用Java或C#语言的示例
或者只是指给我一个公式或方法就行。
谢谢。
**以上计算是实际上用于计算我地图中阴影级别的虚拟点,并用于阴影区域插值目的*
双>代表一个观点;
//你可能有你自己的类型
public static IList< Tuple< Double,Double>> SplitLine(
Tuple< Double,Double> a,
Tuple< Double,Double> b,
int count){
count = count + 1;
Double d = Math.Sqrt((a.Item1 - b.Item1)*(a.Item1 - b.Item1)+(a.Item2 - b.Item2)*(a.Item2 - b.Item2))/ count;
Double fi = Math.Atan2(b.Item2 - a.Item2,b.Item1 - a.Item1);
List< Tuple< Double,Double>> points = new List< Tuple< Double,Double>>(count + 1);
for(int i = 0; i <= count; ++ i)
points.Add(new Tuple< Double,Double>(a.Item1 + i * d * Math .Cos(fi),a.Item2 + i * d * Math.Sin(fi)));
回报点;
}
...
IList< Tuple< Double,Double>>点= SplitLine(
新元组< Double,Double>(35.163,128.001),
新元组< Double,Double>(36.573,128.707),
8);
结果(分):
<$ p $ (35,163,128,001)// < - 初始点A
(35,3196666666667,128,079444444444)
(35,4763333333333,128,157888888889)$ b $ b(35,633,128,236333333333)
(35,7896666666667,128,314777777778)
(35,9463333333333,128,393222222222)
(36,103,128,471666666667)
36,2596666666667,128,550111111111)
(36,4163333333333,128,628555555556)
(36,573,128,707)// < - 最终点B
I have point A (35.163 , 128.001)
and point B (36.573 , 128.707)
I need to calculate the points lies within point A and point B
using the standard distance formula between 2 points, I found D = 266.3
each of the points lies within the line AB (the black point p1, p2, ... p8) are separated with equal distance of d = D / 8 = 33.3
How could I calculate the X and Y for p1 , p2, ... p8?
example of Java or C# language are welcomed
or just point me a formula or method will do.
Thank you.
**The above calculation is actually used to calculate the dummy point for shaded level in my map and working for shaded area interpolation purpose*
Straitforward trigonometric solution could be something like that:
// I've used Tupple<Double, Double> to represent a point;
// You, probably have your own type for it
public static IList<Tuple<Double, Double>> SplitLine(
Tuple<Double, Double> a,
Tuple<Double, Double> b,
int count) {
count = count + 1;
Double d = Math.Sqrt((a.Item1 - b.Item1) * (a.Item1 - b.Item1) + (a.Item2 - b.Item2) * (a.Item2 - b.Item2)) / count;
Double fi = Math.Atan2(b.Item2 - a.Item2, b.Item1 - a.Item1);
List<Tuple<Double, Double>> points = new List<Tuple<Double, Double>>(count + 1);
for (int i = 0; i <= count; ++i)
points.Add(new Tuple<Double, Double>(a.Item1 + i * d * Math.Cos(fi), a.Item2 + i * d * Math.Sin(fi)));
return points;
}
...
IList<Tuple<Double, Double>> points = SplitLine(
new Tuple<Double, Double>(35.163, 128.001),
new Tuple<Double, Double>(36.573, 128.707),
8);
Outcome (points):
(35,163, 128,001) // <- Initial point A
(35,3196666666667, 128,079444444444)
(35,4763333333333, 128,157888888889)
(35,633, 128,236333333333)
(35,7896666666667, 128,314777777778)
(35,9463333333333, 128,393222222222)
(36,103, 128,471666666667)
(36,2596666666667, 128,550111111111)
(36,4163333333333, 128,628555555556)
(36,573, 128,707) // <- Final point B
这篇关于如何计算两个给定点和给定距离之间的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!