Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94923103
penduleressortdesc.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 11, 10:38
Size
3 KB
Mime Type
text/x-c
Expires
Fri, Dec 13, 10:38 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22900554
Attached To
rSYMKIT symkit
penduleressortdesc.cpp
View Options
#include "penduleressortdesc.h"
#include <cmath>
PenduleRessort
::
PenduleRessort
(
const
std
::
vector
<
double
>&
p
,
const
std
::
vector
<
double
>&
p_p
,
const
double
&
k
,
const
double
&
l
,
const
double
&
m1
,
const
double
&
m2
,
const
double
&
fr1
,
const
double
&
fr2
,
const
double
&
g
,
integral_operation
op
)
:
Oscillateur
(
p
,
p_p
,
op
),
k
(
k
),
l
(
l
),
g
(
g
)
{
m
[
0
]
=
m1
;
m
[
1
]
=
m2
;
fr
[
0
]
=
fr1
;
fr
[
1
]
=
fr2
;
//corriger la dimension de position et vitesse
adjust
(
2
);
}
PenduleRessort
::
PenduleRessort
(
const
Vector
&
p
,
const
Vector
&
p_p
,
const
double
&
k
,
const
double
&
l
,
const
double
&
m1
,
const
double
&
m2
,
const
double
&
fr1
,
const
double
&
fr2
,
const
double
&
g
,
integral_operation
op
)
:
Oscillateur
(
p
,
p_p
,
op
),
k
(
k
),
l
(
l
),
g
(
g
)
{
m
[
0
]
=
m1
;
m
[
1
]
=
m2
;
fr
[
0
]
=
fr1
;
fr
[
1
]
=
fr2
;
//corriger la dimension de position et vitesse
adjust
(
2
);
}
double
PenduleRessort
::
getLenght
()
const
{
return
l
;
}
double
PenduleRessort
::
getk
()
const
{
return
k
;
}
#define CHECK_BOUND_INDEX(index) index < 2 && index >= 0
#include "skerror.h"
using
namespace
symkit
;
double
PenduleRessort
::
getMass
(
int
index
)
const
{
if
(
CHECK_BOUND_INDEX
(
index
))
return
m
[
index
];
else
throw
SKError
(
ERR_BOUND
,
"getMass"
,
"PenduleRessort"
,
"Looking for a non-existing value"
,
false
);
}
double
PenduleRessort
::
getFrottement
(
int
index
)
const
{
if
(
CHECK_BOUND_INDEX
(
index
))
return
fr
[
index
];
else
throw
SKError
(
ERR_BOUND
,
"getFrottement"
,
"PenduleRessort"
,
"Looking for a non-existing value"
,
false
);
}
double
PenduleRessort
::
getg
()
const
{
return
g
;
}
void
PenduleRessort
::
setLenght
(
const
double
&
l
)
{
this
->
l
=
l
;
}
void
PenduleRessort
::
setk
(
const
double
&
k
)
{
this
->
k
=
k
;
}
void
PenduleRessort
::
setMass
(
const
double
&
m
,
int
index
)
{
if
(
CHECK_BOUND_INDEX
(
index
))
this
->
m
[
index
]
=
m
;
else
throw
SKError
(
ERR_BOUND
,
"setMass"
,
"PenduleRessort"
,
"Looking for a non-existing memory-buffer"
,
false
);
}
void
PenduleRessort
::
setFrottement
(
const
double
&
fr
,
int
index
)
{
if
(
CHECK_BOUND_INDEX
(
index
))
this
->
fr
[
index
]
=
fr
;
else
throw
SKError
(
ERR_BOUND
,
"setFrottement"
,
"PenduleRessort"
,
"Looking for a non-existing memory-buffer"
,
false
);
}
void
PenduleRessort
::
setg
(
const
double
&
g
)
{
this
->
g
=
g
;
}
void
PenduleRessort
::
setPenduleAngle
(
double
value
)
{
p
[
1
]
=
value
;
}
void
PenduleRessort
::
setPenduleSpeed
(
double
value
)
{
p_prime
[
1
]
=
value
;
}
void
PenduleRessort
::
setRessortPosition
(
double
value
)
{
p
[
0
]
=
value
;
}
void
PenduleRessort
::
setRessortSpeed
(
double
value
)
{
p_prime
[
0
]
=
value
;
}
double
PenduleRessort
::
getPenduleAngle
()
const
{
return
p
[
1
];
}
double
PenduleRessort
::
getPenduleSpeed
()
const
{
return
p_prime
[
1
];
}
double
PenduleRessort
::
getRessortPosition
()
const
{
return
p
[
0
];
}
double
PenduleRessort
::
getRessortSpeed
()
const
{
return
p_prime
[
0
];
}
Vector
PenduleRessort
::
equation
()
const
{
double
a
(
m
[
0
]
+
m
[
1
]
*
sin
(
p
[
1
])
*
sin
(
p
[
1
]));
double
b
(
k
*
p
[
0
]
+
fr
[
0
]
*
p_prime
[
0
]
-
m
[
1
]
*
l
*
p_prime
[
1
]
*
p_prime
[
1
]
*
sin
(
p
[
1
]));
double
c
(
g
*
sin
(
p
[
1
])
+
fr
[
1
]
*
p_prime
[
1
]);
return
{
(
-
b
+
m
[
1
]
*
c
*
cos
(
p
[
1
]))
/
a
,
(
b
*
cos
(
p
[
1
])
-
(
m
[
0
]
+
m
[
1
])
*
c
)
/
(
l
*
a
)
};
}
double
PenduleRessort
::
energy
()
const
{
double
k
(
0.5
*
p_prime
[
0
]
*
p_prime
[
0
]
*
m
[
0
]
+
0.5
*
m
[
1
]
*
(
p_prime
[
1
]
*
p_prime
[
1
]
*
l
*
l
+
p_prime
[
0
]
*
p_prime
[
0
]));
double
u
(
0.5
*
p
[
0
]
*
p
[
0
]
*
this
->
k
-
m
[
1
]
*
g
*
cos
(
p
[
1
]));
return
k
+
u
;
}
Event Timeline
Log In to Comment