Minalistic community edition (CE) library
This commit is contained in:
@@ -1,52 +1,55 @@
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
* ##### # # # *
|
||||
* #### ##### ###### # # # # # # # *
|
||||
* # # # # # ## # # # # # *
|
||||
* # # # # ##### # # # # #### # ### *
|
||||
* # # ##### # # # # # # # # # # *
|
||||
* # # # # # ## # # # # # # *
|
||||
* #### # ###### # # ##### ##### # # *
|
||||
* *
|
||||
* Edward Garemo and Mattia Montanari *
|
||||
* University of Oxford 2019 *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
* *
|
||||
* This is the header file for the openGJK.c file. It defines the openGJK *
|
||||
* function and it two important structures: bd and simplex. *
|
||||
* *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef __OPENGJK_H__
|
||||
#define __OPENGJK_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "math.h"
|
||||
|
||||
/**
|
||||
* @brief Structure of a body.
|
||||
*/
|
||||
struct bd {
|
||||
int numpoints; /**< Number of points defining the body. */
|
||||
double s[3]; /**< Support mapping computed last. */
|
||||
double **coord; /**< Pointer to pointer to the points' coordinates. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure for a simplex.
|
||||
*/
|
||||
struct simplex {
|
||||
int nvrtx; /**< Number of simplex's vertices. */
|
||||
double vrtx[4][3]; /**< Coordinates of simplex's vertices. */
|
||||
int wids[4]; /**< Label of the simplex's vertices. */
|
||||
double lambdas[4]; /**< Barycentric coordiantes for each vertex. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The GJK algorithm which returns the minimum distance between
|
||||
* two bodies.
|
||||
*/
|
||||
extern double gjk(struct bd, struct bd, struct simplex *);
|
||||
|
||||
#endif
|
||||
// _____ _ _ __ //
|
||||
// / ____| | | |/ / //
|
||||
// ___ _ __ ___ _ __ | | __ | | ' / //
|
||||
// / _ \| '_ \ / _ \ '_ \| | |_ |_ | | < //
|
||||
// | (_) | |_) | __/ | | | |__| | |__| | . \ //
|
||||
// \___/| .__/ \___|_| |_|\_____|\____/|_|\_\ //
|
||||
// | | //
|
||||
// |_| //
|
||||
// //
|
||||
// Copyright 2022 Mattia Montanari, University of Oxford //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify it under //
|
||||
// the terms of the GNU General Public License as published by the Free Software //
|
||||
// Foundation, either version 3 of the License. You should have received a copy //
|
||||
// of the GNU General Public License along with this program. If not, visit //
|
||||
// //
|
||||
// https://www.gnu.org/licenses/ //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT //
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS //
|
||||
// FOR A PARTICULAR PURPOSE. See GNU General Public License for details. //
|
||||
|
||||
#ifndef OPENGJK_H__
|
||||
#define OPENGJK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// @brief Use double as default precision
|
||||
#define gkFloat double
|
||||
|
||||
/// @brief Structure of a body
|
||||
typedef struct gkPolytope_ {
|
||||
int numpoints; // Number of points defining the body
|
||||
gkFloat s[3]; // Support mapping computed last
|
||||
gkFloat **coord; // Points' coordinates
|
||||
} gkPolytope;
|
||||
|
||||
/// @brief Structure of the simplex
|
||||
typedef struct gkSimplex_ {
|
||||
int nvrtx; // Number of simplex's vertices
|
||||
int wids[4]; // Label of the simplex's vertices
|
||||
gkFloat lambdas[4]; // Barycentric coordiantes for each vertex
|
||||
gkFloat vrtx[4][3]; // Coordinates of simplex's vertices
|
||||
} gkSimplex;
|
||||
|
||||
/// @brief Uses the GJK algorithm to compute the minimum distance between two bodies
|
||||
gkFloat compute_minimum_distance(const gkPolytope p_, const gkPolytope q_, gkSimplex *s_);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OPENGJK_H__
|
||||
|
||||
Reference in New Issue
Block a user