Skip to content

Commit bf937bf

Browse files
committed
Dont use expensive rotate
1 parent 22821c1 commit bf937bf

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

src/kite_geometry.jl

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -552,32 +552,15 @@ function deform!(wing::RamAirWing, theta_dist::AbstractVector, delta_dist::Abstr
552552

553553
local_y = zeros(MVec3)
554554
chord = zeros(MVec3)
555+
normal = zeros(MVec3)
555556

556557
for i in 1:wing.n_panels
557558
section1 = wing.non_deformed_sections[i]
558559
section2 = wing.non_deformed_sections[i+1]
559560
local_y .= normalize(section1.LE_point - section2.LE_point)
560561
chord .= section1.TE_point .- section1.LE_point
561-
wing.sections[i].TE_point .= section1.LE_point .+ rotate_v_around_k(chord, local_y, wing.theta_dist[i])
562+
normal .= chord × local_y
563+
@. wing.sections[i].TE_point = section1.LE_point + cos(wing.theta_dist[i]) * chord - sin(wing.theta_dist[i]) * normal
562564
end
563565
return nothing
564566
end
565-
566-
"""
567-
rotate_v_around_k(v, k, θ)
568-
569-
Rotate vector v around axis k by angle θ using Rodrigues' rotation formula.
570-
571-
# Arguments
572-
- `v`: Vector to rotate
573-
- `k`: Rotation axis (will be normalized)
574-
- `θ`: Rotation angle in radians
575-
576-
# Returns
577-
- Rotated vector
578-
"""
579-
function rotate_v_around_k(v, k, θ)
580-
k = normalize(k)
581-
v_rot = v * cos(θ) + (k × v) * sin(θ) + k * (k v) * (1 - cos(θ))
582-
return v_rot
583-
end

0 commit comments

Comments
 (0)