@@ -111,7 +111,7 @@ Create interpolation functions for leading/trailing edges and area.
111111- Tuple of (le_interp, te_interp, area_interp) interpolation functions
112112- Where le_interp and te_interp are tuples themselves, containing the x, y and z interpolations
113113"""
114- function create_interpolations (vertices, circle_center_z, radius, gamma_tip; interp_steps= 40 )
114+ function create_interpolations (vertices, circle_center_z, radius, gamma_tip, R ; interp_steps= 40 )
115115 gamma_range = range (- gamma_tip+ 1e-6 , gamma_tip- 1e-6 , interp_steps)
116116 stepsize = gamma_range. step. hi
117117 vz_centered = [v[3 ] - circle_center_z for v in vertices]
@@ -154,6 +154,11 @@ function create_interpolations(vertices, circle_center_z, radius, gamma_tip; int
154154 areas[j] = last_area + area
155155 end
156156
157+ for j in eachindex (gamma_range)
158+ leading_edges[:, j] .= R * leading_edges[:, j]
159+ trailing_edges[:, j] .= R * trailing_edges[:, j]
160+ end
161+
157162 le_interp = ntuple (i -> linear_interpolation (te_gammas, leading_edges[i, :],
158163 extrapolation_bc= Line ()), 3 )
159164 te_interp = ntuple (i -> linear_interpolation (le_gammas, trailing_edges[i, :],
@@ -322,15 +327,6 @@ function calc_inertia_y_rotation(I_b_tensor)
322327 return I_diag, R_b_p
323328end
324329
325- function align_to_principal! (vertices, I_b_tensor)
326- I_diag, R_b_p = calc_inertia_y_rotation (I_b_tensor)
327- for v in vertices
328- v .= R_b_p * v # transform body frame vertices to principal frame
329- end
330- # the rotation between body frame and principal frame is now zero
331- return I_diag
332- end
333-
334330"""
335331 interpolate_matrix_nans!(matrix::Matrix{Float64})
336332
@@ -416,7 +412,6 @@ mutable struct RamAirWing <: AbstractWing
416412 # Additional fields for RamAirWing
417413 non_deformed_sections:: Vector{Section}
418414 mass:: Float64
419- circle_center_z:: Float64
420415 gamma_tip:: Float64
421416 inertia_tensor:: Matrix{Float64}
422417 center_of_mass:: Vector{Float64}
@@ -473,18 +468,24 @@ function RamAirWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10
473468 vertices, faces = read_faces (obj_path)
474469 center_of_mass = center_to_com! (vertices, faces)
475470 inertia_tensor = calculate_inertia_tensor (vertices, faces, mass, zeros (3 ))
476- align_to_principal && align_to_principal! (vertices, inertia_tensor)
477471
478- circle_center_z, radius, gamma_tip = find_circle_center_and_radius (vertices)
479- le_interp, te_interp, area_interp = create_interpolations (vertices, circle_center_z, radius, gamma_tip; interp_steps)
472+ if align_to_principal
473+ inertia_tensor, R_b_p = calc_inertia_y_rotation (inertia_tensor)
474+ circle_center_z, radius, gamma_tip = find_circle_center_and_radius (vertices)
475+ le_interp, te_interp, area_interp = create_interpolations (vertices, circle_center_z, radius, gamma_tip, R_b_p; interp_steps)
476+ else
477+ circle_center_z, radius, gamma_tip = find_circle_center_and_radius (vertices)
478+ le_interp, te_interp, area_interp = create_interpolations (vertices, circle_center_z, radius, gamma_tip, I (3 ); interp_steps)
479+ end
480+
480481 @info " Writing $info_path "
481- serialize (info_path, (inertia_tensor, center_of_mass, circle_center_z, radius, gamma_tip,
482+ serialize (info_path, (inertia_tensor, center_of_mass, radius, gamma_tip,
482483 le_interp, te_interp, area_interp))
483484 end
484485
485486 @info " Loading kite info from $info_path and polars from $polar_path "
486487 try
487- (inertia_tensor:: Matrix , center_of_mass:: Vector , circle_center_z :: Real ,
488+ (inertia_tensor:: Matrix , center_of_mass:: Vector ,
488489 radius:: Real , gamma_tip:: Real , le_interp, te_interp, area_interp) = deserialize (info_path)
489490
490491 if ! ispath (polar_path)
@@ -519,7 +520,7 @@ function RamAirWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10
519520
520521 RamAirWing (n_panels, spanwise_panel_distribution, spanwise_direction, sections,
521522 refined_sections, remove_nan, non_deformed_sections,
522- mass, circle_center_z, gamma_tip, inertia_tensor, center_of_mass, radius,
523+ mass, gamma_tip, inertia_tensor, center_of_mass, radius,
523524 le_interp, te_interp, area_interp, zeros (n_panels), zeros (n_panels))
524525
525526 catch
0 commit comments