simplex.h
Go to the documentation of this file.
1 /***
2  * libccd
3  * ---------------------------------
4  * Copyright (c)2010 Daniel Fiser <danfis@danfis.cz>
5  *
6  *
7  * This file is part of libccd.
8  *
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>.
12  *
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.
16  */
17 
18 #ifndef __CCD_SIMPLEX_H__
19 #define __CCD_SIMPLEX_H__
20 
21 #include <ccd/compiler.h>
22 #include "support.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
29  ccd_support_t ps[4];
30  int last;
31 };
33 
34 
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);
40 
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);
45 
46 
47 /**** INLINES ****/
48 
49 _ccd_inline void ccdSimplexInit(ccd_simplex_t *s)
50 {
51  s->last = -1;
52 }
53 
54 _ccd_inline int ccdSimplexSize(const ccd_simplex_t *s)
55 {
56  return s->last + 1;
57 }
58 
59 _ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s)
60 {
61  return ccdSimplexPoint(s, s->last);
62 }
63 
64 _ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx)
65 {
66  // here is no check on boundaries
67  return &s->ps[idx];
68 }
69 _ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx)
70 {
71  return &s->ps[idx];
72 }
73 
74 _ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v)
75 {
76  // here is no check on boundaries in sake of speed
77  ++s->last;
78  ccdSupportCopy(s->ps + s->last, v);
79 }
80 
81 _ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a)
82 {
83  ccdSupportCopy(s->ps + pos, a);
84 }
85 
86 _ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size)
87 {
88  s->last = size - 1;
89 }
90 
91 _ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2)
92 {
93  ccd_support_t supp;
94 
95  ccdSupportCopy(&supp, &s->ps[pos1]);
96  ccdSupportCopy(&s->ps[pos1], &s->ps[pos2]);
97  ccdSupportCopy(&s->ps[pos2], &supp);
98 }
99 
100 #ifdef __cplusplus
101 } /* extern "C" */
102 #endif /* __cplusplus */
103 
104 #endif /* __CCD_SIMPLEX_H__ */
ccdSimplexSize
_ccd_inline int ccdSimplexSize(const ccd_simplex_t *s)
Definition: simplex.h:54
ccdSimplexAdd
_ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v)
Definition: simplex.h:74
ccdSimplexSetSize
_ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size)
Definition: simplex.h:86
ccdSimplexSwap
_ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2)
Definition: simplex.h:91
_ccd_support_t
Definition: support.h:27
_ccd_simplex_t::ps
ccd_support_t ps[4]
Definition: simplex.h:44
ccdSimplexSet
_ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a)
Definition: simplex.h:81
ccdSimplexLast
const _ccd_inline ccd_support_t * ccdSimplexLast(const ccd_simplex_t *s)
Definition: simplex.h:59
ccdSimplexPoint
const _ccd_inline ccd_support_t * ccdSimplexPoint(const ccd_simplex_t *s, int idx)
Definition: simplex.h:64
support.h
ccdSimplexPointW
_ccd_inline ccd_support_t * ccdSimplexPointW(ccd_simplex_t *s, int idx)
Definition: simplex.h:69
_ccd_simplex_t
Definition: simplex.h:28
ccdSimplexInit
_ccd_inline void ccdSimplexInit(ccd_simplex_t *s)
Definition: simplex.h:49
_ccd_simplex_t::last
int last
index of last added point
Definition: simplex.h:45
ccdSupportCopy
_ccd_inline void ccdSupportCopy(ccd_support_t *, const ccd_support_t *s)
Definition: support.h:46


fcl
Author(s):
autogenerated on Tue Dec 5 2023 03:40:48