mirror of
https://gitlab.com/MisterBiggs/aero-astro-calc.git
synced 2025-06-16 15:17:18 +00:00
almost added all functions
This commit is contained in:
parent
1b6f3c9cb7
commit
708b29f361
@ -1,4 +1,5 @@
|
|||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
from numpy import tan, pi
|
||||||
|
|
||||||
|
|
||||||
class Inertia:
|
class Inertia:
|
||||||
@ -6,9 +7,68 @@ class Inertia:
|
|||||||
self.area = area
|
self.area = area
|
||||||
self.centroid = centroid
|
self.centroid = centroid
|
||||||
|
|
||||||
def __add__(self, other):
|
self.sections = [self]
|
||||||
AX = self.area * self.centroid[0] + other.area * other.centroid[0]
|
|
||||||
AY = self.area * self.centroid[1] + other.area * other.centroid[1]
|
def __add__(self, other):
|
||||||
self.area = self.area + other.area
|
sections = self.sections[:]
|
||||||
self.centroid = (AX / self.area, AY / self.area)
|
sections.extend(other.sections[:])
|
||||||
|
|
||||||
|
A = 0
|
||||||
|
AX = 0
|
||||||
|
AY = 0
|
||||||
|
|
||||||
|
for section in sections:
|
||||||
|
A += section.area
|
||||||
|
AX += section.area * section.centroid[0]
|
||||||
|
AY += section.area * section.centroid[1]
|
||||||
|
|
||||||
|
centroid = (AX / A, AY / A)
|
||||||
|
inertia = Inertia(A, centroid)
|
||||||
|
inertia.sections = sections[:]
|
||||||
|
|
||||||
|
return inertia
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"Area: {self.area}, Centroid: {self.centroid}"
|
||||||
|
|
||||||
|
def Ixx(self):
|
||||||
|
return sum(
|
||||||
|
[
|
||||||
|
section.area * (section.centroid[1] - self.centroid[1]) ** 2
|
||||||
|
for section in self.sections
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def Iyy(self):
|
||||||
|
return sum(
|
||||||
|
[
|
||||||
|
section.area * (section.centroid[0] - self.centroid[0]) ** 2
|
||||||
|
for section in self.sections
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def Ixy(self):
|
||||||
|
return sum(
|
||||||
|
[
|
||||||
|
section.area
|
||||||
|
* (section.centroid[0] - self.centroid[0])
|
||||||
|
* (section.centroid[1] - self.centroid[1])
|
||||||
|
for section in self.sections
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def Iyx(self):
|
||||||
|
return self.Ixy()
|
||||||
|
|
||||||
|
def smiley(self):
|
||||||
|
return self.Ixx() * self.Iyy() - self.Ixy() ** 2
|
||||||
|
|
||||||
|
def x_factor(self, Mx, My):
|
||||||
|
return (My * self.Ixx() - Mx * self.Ixy()) / self.smiley()
|
||||||
|
|
||||||
|
def y_factor(self, Mx, My):
|
||||||
|
return (Mx * self.Iyy() - My * self.Ixy()) / self.smiley()
|
||||||
|
|
||||||
|
# def alpha(self, Mx, My):
|
||||||
|
# return 180 / (tan(self.x_factor(Mx, My) / self.y_factor(Mx, My)) * pi)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user