Skip to content

Commit

Permalink
initial pose transformation
Browse files Browse the repository at this point in the history
still need to implement proper screw transformation matrices with rodrigues rotation
  • Loading branch information
samayala22 committed Mar 1, 2024
1 parent a61dca1 commit d09e661
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions headeronly/linalg.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Forked from:

// linalg.h - 2.2 - Single-header public domain linear algebra library
//
// The intent of this library is to provide the bulk of the functionality
Expand Down
File renamed without changes.
45 changes: 45 additions & 0 deletions tests/test_uvlm_theodorsen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <vector>
#include <string>
#include <fstream>
#include <cmath>
#include <cstdio>

#include "tinycombination.hpp"

#include "vlm.hpp"
#include "vlm_utils.hpp"

using namespace vlm;

int main(int argc, char **argv) {
const std::vector<std::string> meshes = {"../../../../mesh/infinite_rectangular_5x200.x"};
const std::vector<std::string> backends = get_available_backends();

auto solvers = tiny::make_combination(meshes, backends);

for (const auto& [mesh_name, backend_name] : solvers) {

auto translation = [&](f32 t) -> linalg::alias::float4x4 {
return linalg::translation_matrix(linalg::alias::float3{
-1.0f*t,
0.0f,
std::sin(0.2f * t)
});
};

// auto rotation = [&](f32 t) -> linalg::alias::float4x4 {
// return linalg::translation_matrix(linalg::alias::float3{
// -1.0f*t,
// 0.0f,
// std::sin(0.2f * t)
// });
// };

auto wing_pose = [&](f32 t) -> linalg::alias::float4x4 {
return translation(t);
};

}

return 0;
}
File renamed without changes.
8 changes: 8 additions & 0 deletions vlm/include/vlm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,12 @@ class LinearVLM final: public Solver {
AeroCoefficients solve(const FlowData& flow);
};

class UVLM final: public Solver {
public:
UVLM(const tiny::Config& cfg): Solver(cfg) {}
UVLM() = default;
~UVLM() = default;
AeroCoefficients solve(const FlowData& flow);
};

} // namespace vlm
3 changes: 2 additions & 1 deletion vlm/include/vlm_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Mesh {
// ---------------------
u64 nc = 1; // number of panels chordwise
u64 ns = 1; // number of panels spanwise
const u64 nw = 1; // number of panels in chordwise wake
u64 nw = 1; // number of panels in chordwise wake

// Analytical quanities when provided
// ---------------------
Expand Down Expand Up @@ -83,5 +83,6 @@ class Mesh {

// todo, update this to mirror the constructor
std::unique_ptr<Mesh> create_mesh(const std::string& filename);
void mesh_transform(Mesh& mesh, const linalg::alias::float4x4& transform);

} // namespace vlm
10 changes: 10 additions & 0 deletions vlm/src/vlm_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,14 @@ void Mesh::io_read(const std::string& filename) {
} else {
throw std::runtime_error("Failed to open mesh file");
}
}

void vlm::mesh_transform(Mesh& mesh, const linalg::alias::float4x4& transform) {
// like a functional map but over multidimensional elements
for (u64 i = 0; i < mesh.nb_vertices_wing(); i++) {
linalg::alias::float4 transformed_pt = linalg::mul(transform, linalg::alias::float4{mesh.v.x[i], mesh.v.y[i], mesh.v.z[i], 1.f});
mesh.v.x[i] = transformed_pt.x;
mesh.v.y[i] = transformed_pt.y;
mesh.v.z[i] = transformed_pt.z;
}
}

0 comments on commit d09e661

Please sign in to comment.