當前位置:首頁 » 編程語言 » 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

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:765
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:664
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:311
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:289
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:817
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:162
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:94
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:507
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:658
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:481