コード例 #1
0
def plot_3d() -> None:
    ax.scatter(0, 0, 0, color="black")

    colors = ["", "red", "orange", "yellow", "green", "blue", "purple"]
    for k, (tank_center,
            tank_size) in enumerate(zip(Aircraft.OIL_TANK_MIDDLE_POSITION,
                                        Aircraft.OIL_TANK_SIZE),
                                    start=1):
        plot_cube(tank_center, tank_size, colors[k], k)

    plot_line(Point3d(0.0, 0.0, 0.0), Aircraft.OIL_TANK_MIDDLE_POSITION[1])
    plot_line(Point3d(0.0, 0.0, 0.0), Aircraft.OIL_TANK_MIDDLE_POSITION[2])
    plot_line(Point3d(0.0, 0.0, 0.0), Aircraft.OIL_TANK_MIDDLE_POSITION[3])
    plot_line(Point3d(0.0, 0.0, 0.0), Aircraft.OIL_TANK_MIDDLE_POSITION[4])

    plot_line(Aircraft.OIL_TANK_MIDDLE_POSITION[0],
              Aircraft.OIL_TANK_MIDDLE_POSITION[1])
    plot_line(Aircraft.OIL_TANK_MIDDLE_POSITION[5],
              Aircraft.OIL_TANK_MIDDLE_POSITION[4])

    ax.set_xlabel('X', fontsize=16)
    ax.set_ylabel('Y', fontsize=16)
    ax.set_zlabel('Z', fontsize=16)
    ax.set_xlim([-6, 10])
    ax.set_xticks([-6, -4, -2, 0, 2, 4, 6, 8, 10])
    ax.set_xticklabels([-6, -4, -2, 0, 2, 4, 6, 8, 10], fontsize=16)
    ax.set_ylim([-6, 10])
    ax.set_yticks([-6, -4, -2, 0, 2, 4, 6, 8, 10])
    ax.set_yticklabels([-6, -4, -2, 0, 2, 4, 6, 8, 10], fontsize=16)
    ax.set_zlim([-6, 10])
    ax.set_zticks([-6, -4, -2, 0, 2, 4, 6, 8, 10])
    ax.set_zticklabels([-6, -4, -2, 0, 2, 4, 6, 8, 10], fontsize=16)
コード例 #2
0
def calc(ideal_barycenters_np: np.array,
         ideal_oil_consume_mass_np: np.array) -> np.array:
    real_barycenters_list = []
    rest_oil_mass_np = np.array(Aircraft.OIL_TANK_INIT_OIL_MASS)
    max_distance = 0.0
    angle = 0.0
    for time in range(7200):
        time = int(time)

        # TODO: time limit
        if time > 7200:
            break

        ideal_barycenter = ideal_barycenters_np[time]
        ideal_barycenter = Point3d(ideal_barycenter[0], ideal_barycenter[1],
                                   ideal_barycenter[2])
        ideal_oil_consume_mass = ideal_oil_consume_mass_np[time]

        oil_consume_mass_np = evaluate_oil_plan(time, ideal_oil_consume_mass,
                                                rest_oil_mass_np)

        rest_oil_mass_np = rest_oil_mass_np + oil_consume_mass_np
        rest_oil_volume_np = rest_oil_mass_np / Aircraft.OIL_DENSITY_KGpm3
        description = f"time = {time:d}s"
        barycenter_oil, mass_oil = BaryCenter.calc_3d_barycenter_all_tanks(
            Aircraft.OIL_TANK_MIDDLE_POSITION, Aircraft.OIL_TANK_SIZE,
            rest_oil_volume_np.tolist(), math.radians(angle), description)
        real_barycenter, mass = BaryCenter.BaryCenter.compose3d(
            [barycenter_oil, Point3d(0.0, 0.0, 0.0)],
            [mass_oil, Aircraft.AIRCRAFT_NET_WEIGHT])
        real_barycenters_list.append(
            [real_barycenter.x, real_barycenter.y, real_barycenter.z])
        # print(f"{time:d}\t{real_barycenter.x}\t{real_barycenter.y}\t{real_barycenter.z}")
        print(f"{time:d}\t{oil_consume_mass_np.tolist()}")

        distance = distance3d(ideal_barycenter, real_barycenter)
        max_distance = max(max_distance, distance)

    print(f"max_distance = {max_distance}")

    real_barycenters_np = np.array(real_barycenters_list)
    return real_barycenters_np
コード例 #3
0
def calc_3d_barycenter_all_tanks(oil_tank_middle_position_list: List[Point3d], oil_tank_size_list: List[Point3d],
                                 oil_volume_list: List[float], angle: float,
                                 description: str) -> Tuple[Point3d, float]:
    composed_mass = 0.0
    composed_barycenter = Point3d(0.0, 0.0, 0.0)
    for k, (oil_tank_middle_position, oil_tank_size, oil_volume) in \
            enumerate(zip(oil_tank_middle_position_list, oil_tank_size_list, oil_volume_list), start=1):
        description_k = f"{description}, OilTank = No.{k}"
        barycenter, mass = _calc_3d_barycenter(oil_tank_middle_position, oil_tank_size, oil_volume, angle,
                                               description_k)
        composed_barycenter = composed_barycenter + mass * barycenter
        composed_mass = composed_mass + mass
    composed_barycenter = composed_barycenter / composed_mass
    return composed_barycenter, composed_mass
コード例 #4
0
def _calc_3d_barycenter(oil_tank_middle_position: Point3d, oil_tank_size: Point3d,
                        oil_volume: float, angle: float, description: str) -> Tuple[Point3d, float]:
    barycenter2d_tank = _calc_2d_barycenter(oil_tank_size.x, oil_tank_size.z, angle, oil_volume / oil_tank_size.y,
                                            description)
    barycenter2d_aircraft = Point2d(
        math.cos(-angle) * barycenter2d_tank.x - math.sin(-angle) * barycenter2d_tank.y,
        math.sin(-angle) * barycenter2d_tank.x + math.cos(-angle) * barycenter2d_tank.y
    )
    barycenter3d_x = oil_tank_middle_position.x - oil_tank_size.x / 2 + barycenter2d_aircraft.x
    barycenter3d_y = oil_tank_middle_position.y
    barycenter3d_z = oil_tank_middle_position.z - oil_tank_size.z / 2 + barycenter2d_aircraft.y
    barycenter3d = Point3d(barycenter3d_x, barycenter3d_y, barycenter3d_z)
    mass = oil_volume * OIL_DENSITY_KGpm3
    return barycenter3d, mass
コード例 #5
0
import numpy as np
from Point import Point3d

AIRCRAFT_NET_WEIGHT = 3000

OIL_DENSITY_KGpm3 = 850

BARYCENTER_WITHOUT_OIL = Point3d(0.0, 0.0, 0.0)

OIL_TANK_MIDDLE_POSITION = (
    Point3d(8.91304348, 1.20652174, 0.61669004),
    Point3d(6.91304348, -1.39347826, 0.21669004),
    Point3d(-1.68695652, 1.20652174, -0.28330996),
    Point3d(3.11304348, 0.60652174, -0.18330996),
    Point3d(-5.28695652, -0.29347826, 0.41669004),
    Point3d(-2.08695652, -1.49347826, 0.21669004),
)

OIL_TANK_SIZE = (
    Point3d(1.5, 0.9, 0.3),
    Point3d(2.2, 0.8, 1.1),
    Point3d(2.4, 1.1, 0.9),
    Point3d(1.7, 1.3, 1.2),
    Point3d(2.4, 1.2, 1),
    Point3d(2.4, 1, 0.5),
)

OIL_TANK_INIT_OIL_VOLUME = (0.3, 1.5, 2.1, 1.9, 2.6, 0.8)
OIL_TANK_INIT_OIL_MASS = tuple(np.array(OIL_TANK_INIT_OIL_VOLUME) * OIL_DENSITY_KGpm3)

OIL_TANK_MAX_SPEED_KGps = np.array([1.1, 1.8, 1.7, 1.5, 1.6, 1.1])
コード例 #6
0
ファイル: main.py プロジェクト: razdenand/Python_apps
from Point import Point, Point3d, rasst3d, rasst2d
a = Point(3, 1)
b = Point3d(3, 3, 3)
c = Point(2, 1)
d = Point3d(2, 2, 2)
print(rasst3d(b, d))
print(rasst2d(a, c))