日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python计算空间二面角

發布時間:2023/12/9 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python计算空间二面角 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

定義代表三維笛卡爾坐標系上某個點的Point 類(包括x 、y 、z 三個屬性),為該類定義一個方法,可接收second 、third 、forth 三個參數,用于計算當前點、second 、third 組成的面與second 、third 、forth組成的面之間的夾角。
A,B,C,D分別對應于提示point1,point2,point3,point4,線段BC是面ABC與面DBC的公共邊,計算倆面空間夾角: cos (夾角) = (X·Y)/|X||Y|,其中X=AB×BC,Y=BC×CD,X·Y代表X與Y的點積,AB×BC代表AB與BC的叉乘

import mathclass Point():def __init__(self,x,y,z):self.x = xself.y = yself.z = zdef distance(self):xx = (self.x) ** 2yy = (self.y) ** 2zz = (self.z) ** 2return (xx + yy + zz) ** (0.5)def vector(self,other):xx = (self.x - other.x)yy = (self.y - other.y)zz = (self.z - other.z)return Point(xx,yy,zz)def cross(self,other):return Point(self.x*other.z-self.z*other.y , self.z*other.x-self.x*other.z , self.x*other.y-self.y*other.x)def dot(self,other):return (self.x*other.x + self.y*other.y + self.z*other.z)# def dot(self, other):# return Point((self.x * other.x),# (self.y * other.y),# (self.z * other.z))def angle(self,second,third,forth):vertor11 = point1.vector(point2)vertor12 = point1.vector(point3)vertor21 = point4.vector(point2)vertor22 = point4.vector(point3)vertor1 = vertor11.cross(vertor12)vertor2 = vertor21.cross(vertor22)return math.acos( (vertor1.dot(vertor2)) / ((vertor1.distance())*(vertor2.distance())) )point1 = Point(0,1,0) point2 = Point(1,0,0) point3 = Point(0,0,0) point4 = Point(0,0,1)angels = point1.angle(point2,point3,point4) print(math.degrees(angels))

總結

以上是生活随笔為你收集整理的Python计算空间二面角的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。