当前位置:首页 » 编程语言 » python坐标

python坐标

发布时间: 2022-01-10 20:50:21

‘壹’ python求两点间直线所有坐标值

#!/usr/bin/python
#encoding:utf-8
#
#filename:line.py


classPoint:
def__init__(self,x,y):
self.x=x
self.y=y

def__str__(self):
return"(%d,%d)"%(self.x,self.y)

defline2(self,another):
ifself.x==another.x:
step=1ifself.y<another.yelse-1
y=self.y
whiley!=another.y:
yieldPoint(self.x,y)
y+=step
elifself.y==another.y:
step=1ifself.x<another.xelse-1
x=self.x
whilex!=another.x:
yieldPoint(x,self.y)
x+=step
else:
d_x=self.x-another.x
d_y=self.y-another.y
s_x=1ifd_x<0else-1
s_y=1ifd_y<0else-1

ifd_y:
delta=1.*d_x/d_y
foriinxrange(0,d_x):
yieldPoint(self.x+i*s_x,self.y+i*s_x/delta)
elifd_x:
delta=1.*d_y/d_x
foriinxrange(0,d_y):
yieldPoint(self.y+i*s_y/delta,self.y+i*s_y)

deftester():
pointA=Point(450,649)
pointB=Point(326,649)
printpointA,'~',pointB
forpointinpointA.line2(pointB):
print"%s"%point
print"+"*32

pointA=Point(450,649)
pointB=Point(450,863)
printpointA,'~',pointB
forpointinpointA.line2(pointB):
print"%s"%point
print"+"*32

pointA=Point(450,649)
pointB=Point(326,863)
printpointA,'~',pointB
forpointinpointA.line2(pointB):
print"%s"%point

if__name__=="__main__":
tester()

‘贰’ Python 生成随机点坐标

importrandom
importnumpyasnp
List=np.array([(0,0),(1,1),(1.6,1.8),(3,3)])

d=0.5

defget_random(low,high):
return((high-low)*random.random()+low)

n=0
whilen<100000:
x=get_random(0,3)
y=get_random(0,3)
rand_tuple=np.array([x,y])
tmp_dist=np.sqrt(np.sum(np.square(List-rand_tuple),axis=1))
tmp_dist_bool=tmp_dist>=d
ifnp.sum(tmp_dist_bool)==len(List):
print(x,y)
break
n+=1
ifn==100000:
print("After",n,"tries,can'tgetarandompoint!!")

‘叁’ python画图如何得到坐标

画图的默认原点都是左上角,可以设立坐标中心点进行偏移。

‘肆’ python怎么修改Point坐标

def coordinate(x, y):
if x>0:
if y>0:
a = 1
else:
a = 2
else:
if y>0:
a = 3
else:
a = 4
return a #根据x,y返回aif __name__ == "__main":
print 'Please insert X,Y'
x = input('Please insert X')
y = input('Please insert Y')
print coordinate(x,y)

‘伍’ 用python怎么获得网页上任何一个对象的x,y坐标呢

你的要求不容易实现!固定格式的网页内容还好,可以看网页源码进行分析编程。非固定的网页不容易实现。你不会是想编个浏览器吧!

不知道你是基于什么原因提出这样的需求的?可以将你的原因说一说,让大家帮你想想办法。

‘陆’ python从两个列表中取值,生成坐标

for i in X:

for j in Y:

d=[i,j]

print(d)




后面没有截图,太长了,一共144行。

希望可以帮到你

‘柒’ python将高斯坐标转换经纬度 经纬度坐标与高斯坐标的转换代码

#网上搜来的

# 高斯坐标转经纬度算法 # B=大地坐标X # C=大地坐标Y # IsSix=6度带或3度带

import math
def GetLatLon2(B, C,IsSix):
#带号
D = math.trunc( C/ 1000000)

#中央经线(单位:弧度)
K = 0
if IsSix:
K = D * 6 - 3 #6度带计算
else:
K = D * 3 #3度带计算
L = B/(6378245*(1-0.006693421623)*1.0050517739)
M = L +(0.00506237764 * math.sin(2*L)/2-0.00001062451*math.sin(4*L)/4+0.0000002081*math.sin(6*L)/6)/1.0050517739
N = L +(0.00506237764 * math.sin(2*M)/2-0.00001062451*math.sin(4*M)/4+0.0000002081*math.sin(6*M)/6)/1.0050517739
O = L +(0.00506237764 * math.sin(2*N)/2-0.00001062451*math.sin(4*N)/4+0.0000002081*math.sin(6*N)/6)/1.0050517739
P = L +(0.00506237764 * math.sin(2*O)/2-0.00001062451*math.sin(4*O)/4+0.0000002081*math.sin(6*O)/6)/1.0050517739
Q = L +(0.00506237764 * math.sin(2*P)/2-0.00001062451*math.sin(4*P)/4+0.0000002081*math.sin(6*P)/6)/1.0050517739
R = L +(0.00506237764 * math.sin(2*Q)/2-0.00001062451*math.sin(4*Q)/4+0.0000002081*math.sin(6*Q)/6)/1.0050517739
S = math.tan(R)
T = 0.006738525415*(math.cos(R))**2
U = 6378245/math.sqrt(1-0.006693421623*(math.sin(R))**2)
V = 6378245*(1-0.006693421623)/(math.sqrt((1-0.006693421623*(math.sin(R))**2)))**3
W = 5+3*S**2+T-9*T*S**2
X = 61+90*S**2+45*S**4
Y = 1+2*S**2+T**2
Z = 5+28*S**2+24*S**4+6*T+8*T*S**2
Lat= (180/math.pi)*(R-(C-D*1000000-500000)**2*S/(2*V*U)+(C-D*1000000-500000)**4*W/(24*U**3*V)-(C-D*1000000-500000)**6*X/(7200*U**5*V))
Lon= (180/math.pi)*(C-D*1000000-500000)*(1-(C-D*1000000-500000)**2*Y/(6*U**2)+(C-D*1000000-500000)**4*Z/(120*U**4))/(U*math.cos(P))
Lat = Lat
Lon = K + Lon
return (Lon, Lat)

‘捌’ python如何定义坐标


def coordinate(x, y):
if x>0:
if y>0:
a = 1
else:
a = 2
else:
if y>0:
a = 3
else:
a = 4
return a #根据x,y返回aif __name__ == "__main":
print 'Please insert X,Y'
x = input('Please insert X')
y = input('Please insert Y')
print coordinate(x,y)




‘玖’ 在python怎么读取txt文件中的坐标。

importre

withopen('te.txt')asA:
foreachlineinA:
tmp=re.split("s+",eachline.rstrip())
x.append(tmp[0])
y.append(tmp[1])
printx,y

‘拾’ 如何用Python批量获取经纬度坐标

python根据地址获取经纬度方法一:
from geopy.geocoders import Nominatim
#使用geopy查询
def geocodeN(address):
gps=Nominatim()
location=gps.geocode(address)
return location.longitude,location.latitude

使用Geopy包 : github.com/geopy/geopy (仅能精确到城镇,具体街道无结果返回)
另外还有一种使用高德地图或网络地图API的方法,有兴趣的朋友可以参考下。
参考链接:https://panxu.net/article/8382.html

热点内容
安卓端开发用什么IDE 发布:2024-11-15 14:13:51 浏览:554
阿里云查看访问ip 发布:2024-11-15 14:08:58 浏览:544
随机字符串php 发布:2024-11-15 14:03:46 浏览:122
怎样用数据库搭建服务器 发布:2024-11-15 13:58:39 浏览:478
android编码设置 发布:2024-11-15 13:50:02 浏览:907
androidstringchar 发布:2024-11-15 13:45:00 浏览:965
obs配置怎么弄 发布:2024-11-15 13:43:30 浏览:868
特斯拉买哪个配置的 发布:2024-11-15 13:42:36 浏览:557
儿童编程教材 发布:2024-11-15 13:37:34 浏览:43
查询服务器连接地址 发布:2024-11-15 13:27:20 浏览:505