1
0
mirror of https://gitlab.com/MisterBiggs/astro-helper.git synced 2025-06-15 14:46:40 +00:00

added structures

This commit is contained in:
Anson Biggs 2021-01-28 00:34:07 -07:00
parent df3965f8ab
commit fd765a7672
4 changed files with 47 additions and 6 deletions

View File

@ -4,4 +4,5 @@ authors = ["Anson <anson@ansonbiggs.com>"]
version = "0.1.0"
[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

View File

@ -1,7 +1,8 @@
module AstroHelper
using LinearAlgebra
using DataFrames
include("quaternions.jl")
include("aeStructures.jl")
end # module

30
src/aeStructures.jl Normal file
View File

@ -0,0 +1,30 @@
struct Section
data::DataFrame
xc::Float64
yc::Float64
Ixx::Float64
Iyy::Float64
Ixy::Float64
function Section(A, x, y)
d = DataFrame(A=A, x=x, y=y)
d.Ax = d.A .* d.x
d.Ay = d.A .* d.y
xc = sum(d.Ax) / sum(d.A)
yc = sum(d.Ay) / sum(d.A)
Ixx = sum(d.A .* ((d.y .- yc).^2))
Iyy = sum(d.A .* ((d.x .- xc).^2))
Ixy = sum(d.A .* ((d.x .- xc) .* (d.y .- yc)))
new(d, xc, yc, Ixx, Iyy, Ixy)
end
end

View File

@ -1,9 +1,10 @@
using AstroHelper
using Test
import AstroHelper
import AstroHelper: Quaternion, Section
@testset "Quaternion Initialization" begin
@testset "AeroHelper" begin
@testset "Quaternion Initialization" begin
@test Quaternion().r == 1.0
@test Quaternion([0,0,0,1]) == Quaternion()
@test Quaternion([0 0 0], 0) == Quaternion()
@ -13,9 +14,17 @@ import AstroHelper
@test Quaternion(0, 0, pi / 2) Quaternion([1 0 0], pi / 2)
@test_throws ErrorException Quaternion(1, 2, 3, 4)
end
end
@testset "Quaternion Math" begin
# @testset "Quaternion Math" begin
# Quaternion Multiplication is not Communitive.
# @test Quaternion() * Quaternion([0 1 0 0]) != Quaternion([0 1 0 0]) * Quaternion()
# end
@testset "Section" begin
s = Section([2,1,0.5,0.5,0.75,0.75,2], [0,12,24,24,16,8,0], [0,0,0,6,7,8,9])
@test all([s.Ixx == 126.075 s.Iyy == 571.2 s.Ixy -28.2])
end
end