标签: cartesian-coordinates

将小数纬度/经度坐标转换为iPad屏幕坐标

我有一个纬度/经度小数点坐标,我想将其转换为适合iPad坐标系区域的点.

我的代码采用纬度/经度坐标并将它们转换为笛卡尔坐标(基于此问题:转换为笛卡尔坐标)转换结果为(2494.269287,575.376465).

这是我的代码(没有编译或运行时错误):

#define EARTH_RADIUS 6371

- (void)drawRect:(CGRect)rect
{
    CGPoint latLong = {41.998035, -116.012215};

    CGPoint newCoord = [self convertLatLongCoord:latLong];

    NSLog(@"Cartesian Coordinate: (%f, %f)",newCoord.x, newCoord.y);

    //Draw dot at coordinate
    CGColorRef darkColor = [[UIColor colorWithRed:21.0/255.0
                                            green:92.0/255.0
                                             blue:136.0/255.0
                                            alpha:1.0] CGColor];
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, darkColor);
    CGContextFillRect(context, CGRectMake(newCoord.x, newCoord.y, 100, 100));

}

-(CGPoint)convertLatLongCoord:(CGPoint)latLong
{
    CGFloat x = EARTH_RADIUS * cos(latLong.x) * cos(latLong.y);
    CGFloat y = EARTH_RADIUS * cos(latLong.x) * sin(latLong.y);

    return CGPointMake(x, y);
}
Run Code Online (Sandbox Code Playgroud)

如何将小数点坐标转换为将显示在iPad屏幕上的坐标?

objective-c latitude-longitude ios cartesian-coordinates

3
推荐指数
1
解决办法
3091
查看次数

将 3D 极坐标转换为笛卡尔坐标

我一直在对这种转换背后的数学进行大量搜索,到目前为止我能想到的最好的方法是:

x = sin(horizontal_angle) * cos(vertical_angle)
y = sin(horizontal_angle) * sin(vertical_angle)
z = cos(horizontal_angle)
Run Code Online (Sandbox Code Playgroud)

对于任意角度,这都很好。我遇到问题的地方是当其中一个旋转为 0 度时。在 0 度(或 180、或 360,或...)时,sin() 将为零,这意味着我从上述公式中得到的 x 和 y 坐标都将为零,无论其他角度如何被设置为。

有没有更好的公式,在某些角度不会混乱?到目前为止我的搜索还没有找到,但必须有一个解决方案来解决这个问题。

更新: 经过一些实验,我发现我的主要误解是我假设球坐标的极点是垂直的(就像行星上的纬度和经度),而它们实际上是水平的(投影到屏幕上)。这是因为我在屏幕空间(x/y 映射到屏幕,z 投影到屏幕)中工作,而不是传统的 3D 环境,但不知怎的,我并不认为这会成为一个影响因素。

最终的公式对我有用,使两极正确定向:

x = cos(horizontal_angle) * sin(vertical_angle)
y = cos(vertical_angle)
z = sin(horizontal_angle) * sin(vertical_angle)
Run Code Online (Sandbox Code Playgroud)

math rotation polar-coordinates cartesian-coordinates

3
推荐指数
2
解决办法
2万
查看次数

如何操作Python中的笛卡尔坐标?

我有一组基本的笛卡尔坐标,我想用Python操作它们.例如,我有以下框(坐标显示为角):

0,4 --- 4,4

0,0 --- 4,0

我希望能够找到一个以(0,2)开头并转到(4,2)的行.我是否需要将每个坐标分解为单独的X和Y值然后使用基本数学,或者有没有办法将坐标作为(x,y)对处理?例如,我想说:

New_Row_Start_Coordinate = (0,2) + (0,0)
New_Row_End_Coordinate = New_Row_Start_Coordinate + (0,4)
Run Code Online (Sandbox Code Playgroud)

python coordinates cartesian-coordinates

3
推荐指数
1
解决办法
5989
查看次数

在直角坐标中沿给定方向在距离上移动点

我在笛卡尔坐标系中有一个点,例如: x = 3y = 5

我想在给定方向(以度为单位)上移动一段距离后,获得该点的新坐标。

如何获得新的x和新的y?

math geometry polar-coordinates cartesian-coordinates

3
推荐指数
1
解决办法
2264
查看次数

MPandroidchart - 当用户向上或向下或向右或向左滚动时,我想添加更多点

Initially the graph goes from -10 to 10 but i want that when the user scrolls right the values are evaluated and the graph "grows". Is there any listeners for that. I meant that when the user scrolls to the right then i add more points as for function, there is always a value of y for an x. The graph keep constructing itself when the user scrolls up down right or left.

android graph cartesian-coordinates mpandroidchart

2
推荐指数
1
解决办法
808
查看次数

将球坐标转换为笛卡尔坐标

我正在尝试将球坐标转换为笛卡尔坐标以绘制一个简单的 3D 金字塔。

这是获取金字塔四个主要角的代码,具体取决于极角 yrad 和方位角 xrad 以及顶峰坐标 x 和 y:

xpos1 = x+25*(      sin(yrad+pi/2+pi/4)*cos(-xrad+pi/2+pi/4));
zpos1 = y-35+25*(   cos(yrad+pi/2+pi/4)); 
xpos2 = x+25*(      sin(yrad+pi/2-pi/4)*cos(-xrad+pi/2+pi/4));
zpos2 = y-35+25*(   cos(yrad+pi/2-pi/4)); 
xpos3 = x+25*(      sin(yrad+pi/2-pi/4)*cos(-xrad+pi/2-pi/4));
zpos3 = y-35+25*(   cos(yrad+pi/2-pi/4)); 
xpos4 = x+25*(      sin(yrad+pi/2+pi/4)*cos(-xrad+pi/2-pi/4));
zpos4 = y-35+25*(   cos(yrad+pi/2+pi/4)); 
Run Code Online (Sandbox Code Playgroud)

方位角轴似乎工作正常,但问题是在操纵极角时,左右在经过天顶或底部时会交换,如下所示(选择顶部的 mp4 以获得更流畅的播放): http: //gyazo.com/4a245713c232893960863cf4ea4186f6

怎么了?

3d trigonometry coordinate-systems cartesian-coordinates

1
推荐指数
1
解决办法
1369
查看次数

从一组坐标中确定将形成一条线的点

我想编写一个程序,在笛卡尔平面上生成 10 - 100 个随机坐标,并且它应该找到哪些点将形成一条线。

它应该是至少四个可以形成一条线的点的组合。为此,我可以找到四个选定点之间的斜率,以确定它们是否可以形成一条线。

然而,困难的部分是如何将所有点组合起来?我想使用蛮力方法,找到至少四个点的所有组合,然后检查它们之间的斜率,看看它们是否可以形成一条线。

关于如何解决这个问题的任何建议(例如有效地找到组合)将不胜感激。

c++ algorithm linear-algebra cartesian-coordinates

0
推荐指数
1
解决办法
2087
查看次数