1 /* Siconos is a program dedicated to modeling, simulation and control 2 * of non smooth dynamical systems. 3 * 4 * Copyright 2021 INRIA. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 20 /** \file DiskPlanR.hpp 21 */ 22 23 #ifndef DiskPlanR_h 24 #define DiskPlanR_h 25 26 #include "MechanicsFwd.hpp" 27 #include "LagrangianScleronomousR.hpp" 28 29 /** \class DiskPlanR 30 * \brief disk - plan relation - Inherits from LagrangianScleronomousR 31 */ 32 class DiskPlanR : public LagrangianScleronomousR, public std::enable_shared_from_this<DiskPlanR> 33 { 34 private: 35 /** serialization hooks 36 */ 37 ACCEPT_SERIALIZATION(DiskPlanR); 38 39 double r, A, B, C, sqrA2pB2, 40 AC, B2, A2, AB, BC, xCenter, yCenter, width, halfWidth, x1, x2, y1, y2; 41 bool finite; 42 43 void init(double, double, double, double, double, double, double); 44 DiskPlanR()45 DiskPlanR() : LagrangianScleronomousR() {}; 46 47 public: 48 49 /** Infinite Plan 50 51 \param r disk radius 52 \param A component of line equation Ax + By + C = 0 53 \param B component of line equation Ax + By + C = 0 54 \param C component of line equation Ax + By + C = 0 55 */ 56 DiskPlanR(double r, double A, double B, double C); 57 58 /** Finite or infinite Plan (segment) 59 60 \param disk radius 61 \param A 62 \param B 63 \param C 64 \param xCenter 65 \param yCenter 66 \param width 67 */ 68 DiskPlanR(double disk, double A, double B, double C, 69 double xCenter, double yCenter, double width); 70 71 /** Finite Plan 72 */ 73 DiskPlanR(double, double, double, double, double); 74 75 /* distance between disk and plan */ 76 double distance(double x, double y, double r) const; 77 getRadius() const78 double getRadius() const 79 { 80 return r; 81 }; 82 getA() const83 double getA() const 84 { 85 return A; 86 }; 87 getB() const88 double getB() const 89 { 90 return B; 91 }; 92 getC() const93 double getC() const 94 { 95 return C; 96 }; 97 gethypotAB() const98 double gethypotAB() const 99 { 100 return sqrA2pB2; 101 }; 102 getXCenter() const103 double getXCenter() const 104 { 105 return xCenter; 106 }; 107 getYCenter() const108 double getYCenter() const 109 { 110 return yCenter; 111 }; 112 getWidth() const113 double getWidth() const 114 { 115 return width; 116 }; 117 118 using LagrangianScleronomousR::computeh; 119 /** to compute the output y = h(t,q,z) of the Relation 120 \param q coordinates of the dynamical systems involved in the relation 121 \param z user defined parameters (optional) 122 \param y the resulting vector 123 */ 124 void computeh(const BlockVector& q, BlockVector& z, SiconosVector& y); 125 126 /** to compute the jacobian of h(...). Set attribute _jachq (access: jacqhq()) 127 \param q coordinates of the dynamical systems involved in the relation 128 \param z user defined parameters (optional) 129 */ 130 void computeJachq(const BlockVector& q, BlockVector& z); 131 132 bool equal(double, double, double, double) const; 133 134 bool equal(double, double, double, double, double, double, double) const; 135 136 bool equal(const DiskPlanR&) const; 137 isFinite() const138 bool isFinite() const 139 { 140 return finite; 141 }; 142 143 /** visitor hooks 144 */ 145 ACCEPT_VISITORS(); 146 ~DiskPlanR()147 ~DiskPlanR() {}; 148 149 }; 150 #endif /* DiskPlanR */ 151 152