Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ode/ode-0.9/ode/src/cylinder.cpp @ 216

Last change on this file since 216 was 216, checked in by mathiask, 16 years ago

[Physik] add ode-0.9

File size: 3.5 KB
Line 
1/*************************************************************************
2 *                                                                       *
3 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith.       *
4 * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
5 *                                                                       *
6 * This library is free software; you can redistribute it and/or         *
7 * modify it under the terms of EITHER:                                  *
8 *   (1) The GNU Lesser General Public License as published by the Free  *
9 *       Software Foundation; either version 2.1 of the License, or (at  *
10 *       your option) any later version. The text of the GNU Lesser      *
11 *       General Public License is included with this library in the     *
12 *       file LICENSE.TXT.                                               *
13 *   (2) The BSD-style license that is included with this library in     *
14 *       the file LICENSE-BSD.TXT.                                       *
15 *                                                                       *
16 * This library is distributed in the hope that it will be useful,       *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
20 *                                                                       *
21 *************************************************************************/
22
23/*
24
25standard ODE geometry primitives: public API and pairwise collision functions.
26
27the rule is that only the low level primitive collision functions should set
28dContactGeom::g1 and dContactGeom::g2.
29
30*/
31
32#include <ode/common.h>
33#include <ode/collision.h>
34#include <ode/matrix.h>
35#include <ode/rotation.h>
36#include <ode/odemath.h>
37#include "collision_kernel.h"
38#include "collision_std.h"
39#include "collision_util.h"
40
41#ifdef _MSC_VER
42#pragma warning(disable:4291)  // for VC++, no complaints about "no matching operator delete found"
43#endif
44
45// flat cylinder public API
46
47dxCylinder::dxCylinder (dSpaceID space, dReal _radius, dReal _length) :
48dxGeom (space,1)
49{
50        dAASSERT (_radius > 0 && _length > 0);
51        type = dCylinderClass;
52        radius = _radius;
53        lz = _length;
54}
55
56
57void dxCylinder::computeAABB()
58{
59    const dMatrix3& R = final_posr->R;
60    const dVector3& pos = final_posr->pos;
61
62        dReal xrange = dFabs (R[0] * radius) +   dFabs (R[1] * radius) + REAL(0.5)* dFabs (R[2] * 
63                lz);
64        dReal yrange = dFabs (R[4] * radius) +   dFabs (R[5] * radius) + REAL(0.5)* dFabs (R[6] * 
65                lz);
66        dReal zrange = dFabs (R[8] * radius) +   dFabs (R[9] * radius) + REAL(0.5)* dFabs (R[10] * 
67                lz);
68        aabb[0] = pos[0] - xrange;
69        aabb[1] = pos[0] + xrange;
70        aabb[2] = pos[1] - yrange;
71        aabb[3] = pos[1] + yrange;
72        aabb[4] = pos[2] - zrange;
73        aabb[5] = pos[2] + zrange;
74}
75
76
77dGeomID dCreateCylinder (dSpaceID space, dReal radius, dReal length)
78{
79        return new dxCylinder (space,radius,length);
80}
81
82void dGeomCylinderSetParams (dGeomID cylinder, dReal radius, dReal length)
83{
84        dUASSERT (cylinder && cylinder->type == dCylinderClass,"argument not a ccylinder");
85        dAASSERT (radius > 0 && length > 0);
86        dxCylinder *c = (dxCylinder*) cylinder;
87        c->radius = radius;
88        c->lz = length;
89        dGeomMoved (cylinder);
90}
91
92void dGeomCylinderGetParams (dGeomID cylinder, dReal *radius, dReal *length)
93{
94        dUASSERT (cylinder && cylinder->type == dCylinderClass,"argument not a ccylinder");
95        dxCylinder *c = (dxCylinder*) cylinder;
96        *radius = c->radius;
97        *length = c->lz;
98}
99
100
Note: See TracBrowser for help on using the repository browser.