3
* ---------------------------------
4
* Copyright (c)2010 Daniel Fiser <danfis@danfis.cz>
7
* This file is part of libccd.
9
* Distributed under the OSI-approved BSD License (the "License");
10
* see accompanying file BDS-LICENSE for details or see
11
* <http://www.opensource.org/licenses/bsd-license.php>.
13
* This software is distributed WITHOUT ANY WARRANTY; without even the
14
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
* See the License for more information.
18
#ifndef __CCD_SIMPLEX_H__
19
#define __CCD_SIMPLEX_H__
21
#include <ccd/compiler.h>
26
#endif /* __cplusplus */
28
struct _ccd_simplex_t {
30
int last; //!< index of last added point
32
typedef struct _ccd_simplex_t ccd_simplex_t;
35
_ccd_inline void ccdSimplexInit(ccd_simplex_t *s);
36
_ccd_inline int ccdSimplexSize(const ccd_simplex_t *s);
37
_ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s);
38
_ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx);
39
_ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx);
41
_ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v);
42
_ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a);
43
_ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size);
44
_ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2);
49
_ccd_inline void ccdSimplexInit(ccd_simplex_t *s)
54
_ccd_inline int ccdSimplexSize(const ccd_simplex_t *s)
59
_ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s)
61
return ccdSimplexPoint(s, s->last);
64
_ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx)
66
// here is no check on boundaries
69
_ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx)
74
_ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v)
76
// here is no check on boundaries in sake of speed
78
ccdSupportCopy(s->ps + s->last, v);
81
_ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a)
83
ccdSupportCopy(s->ps + pos, a);
86
_ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size)
91
_ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2)
95
ccdSupportCopy(&supp, &s->ps[pos1]);
96
ccdSupportCopy(&s->ps[pos1], &s->ps[pos2]);
97
ccdSupportCopy(&s->ps[pos2], &supp);
102
#endif /* __cplusplus */
104
#endif /* __CCD_SIMPLEX_H__ */