-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from SimonRohou/codac2_dev
Revised functions + trajectory operators
- Loading branch information
Showing
71 changed files
with
1,853 additions
and
1,270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# ================================================================== | ||
# codac / basics example - cmake configuration file | ||
# ================================================================== | ||
|
||
cmake_minimum_required(VERSION 3.0.2) | ||
project(codac_example LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Adding IBEX | ||
|
||
# In case you installed IBEX in a local directory, you need | ||
# to specify its path with the CMAKE_PREFIX_PATH option. | ||
# set(CMAKE_PREFIX_PATH "~/ibex-lib/build_install") | ||
|
||
find_package(IBEX REQUIRED) | ||
ibex_init_common() # IBEX should have installed this function | ||
message(STATUS "Found IBEX version ${IBEX_VERSION}") | ||
|
||
# Adding Codac | ||
|
||
# In case you installed Codac in a local directory, you need | ||
# to specify its path with the CMAKE_PREFIX_PATH option. | ||
# set(CMAKE_PREFIX_PATH "~/codac/build_install") | ||
|
||
find_package(CODAC REQUIRED) | ||
message(STATUS "Found Codac version ${CODAC_VERSION}") | ||
|
||
# Compilation | ||
|
||
if(FAST_RELEASE) | ||
add_compile_definitions(FAST_RELEASE) | ||
message(STATUS "You are running Codac in fast release mode. (option -DCMAKE_BUILD_TYPE=Release is required)") | ||
endif() | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS}) | ||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS}) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC ${CODAC_LIBRARIES} Ibex::ibex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Example: A sampled trajectory, 'sampled_f' (composed of time-stamped positions with | ||
// linear interpolation between them), is first obtained by discretizing an analytical | ||
// expression (the function 'f,' which represents a Lissajous curve) and then appending | ||
// an additional position. This trajectory is subsequently used in another analytical | ||
// expression (function 'h'). The projection of an inverse separator is then employed | ||
// to validate the result. | ||
|
||
#include <codac> | ||
|
||
using namespace codac2; | ||
|
||
int main() | ||
{ | ||
ScalarVar t; | ||
AnalyticFunction f { | ||
{t}, | ||
{ 2*cos(t), sin(2*t) } | ||
}; | ||
|
||
Interval tdomain(0,5); | ||
auto sampled_f = AnalyticTrajectory(f,tdomain).sampled(0.8); | ||
sampled_f[6] = {0,-1}; | ||
|
||
VectorVar w(3); | ||
auto g = sampled_f.as_function(); | ||
AnalyticFunction h { | ||
{w}, | ||
sqr(w[0]-g(w[2])[0])+sqr(w[1]-g(w[2])[1]) | ||
}; | ||
|
||
SepInverse s_h(h, {0,0.1}); | ||
SepProj s_projh(s_h, {0,1}, {sampled_f.tdomain()}); | ||
|
||
DefaultView::set_window_properties({75,75},{700,700}); | ||
draw_while_paving({{-3,3},{-2,2}}, s_projh, 5e-2); | ||
DefaultView::draw_trajectory(sampled_f); | ||
DefaultView::draw_trajectory(AnalyticTrajectory(f,tdomain), Color::dark_gray()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from codac import * | ||
|
||
# Example: A sampled trajectory, 'sampled_f' (composed of time-stamped positions with | ||
# linear interpolation between them), is first obtained by discretizing an analytical | ||
# expression (the function 'f,' which represents a Lissajous curve) and then appending | ||
# an additional position. This trajectory is subsequently used in another analytical | ||
# expression (function 'h'). The projection of an inverse separator is then employed | ||
# to validate the result. | ||
|
||
t = ScalarVar() | ||
f = AnalyticFunction( | ||
[t], | ||
[ 2*cos(t), sin(2*t) ] | ||
) | ||
|
||
tdomain = [0,5] | ||
sampled_f = AnalyticTrajectory(f,tdomain).sampled(0.8) | ||
sampled_f[6] = [0,-1] | ||
|
||
w = VectorVar(3) | ||
g = sampled_f.as_function() | ||
h = AnalyticFunction( | ||
[w], | ||
sqr(w[0]-g(w[2])[0])+sqr(w[1]-g(w[2])[1]) | ||
) | ||
|
||
s_h = SepInverse(h, [0,0.1]) | ||
s_projh = SepProj(s_h, [0,1], [sampled_f.tdomain()]) | ||
|
||
DefaultView.set_window_properties([75,75],[700,700]) | ||
draw_while_paving([[-3,3],[-2,2]], s_projh, 5e-2) | ||
DefaultView.draw_trajectory(sampled_f) | ||
DefaultView.draw_trajectory(AnalyticTrajectory(f,tdomain), Color.dark_gray()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.