Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94256455
newton.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
Thu, Dec 5, 04:48
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Dec 7, 04:48 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22771434
Attached To
rSYMKIT symkit
newton.cpp
View Options
#include "newton.h"
#include "integrators.h"
using
namespace
symkit
;
NewtonDescriptor
::
NewtonDescriptor
(
const
NewtonDescriptor
&
desc
)
{
*
this
=
desc
;
}
NewtonDescriptor
::
NewtonDescriptor
(
const
double
&
mass
,
const
SVector
<
3
>
&
position
,
const
SVector
<
3
>
&
speed
)
:
mass
(
mass
),
position
(
position
),
speed
(
speed
),
forces
(
SVector
<
3
>::
nullv
)
{
}
const
double
NewtonDescriptor
::
sq_speed_zero
=
1.0e-6
;
void
NewtonDescriptor
::
update
(
float
dt
)
{
integrateEulerCromer
<
SVector
<
3
>>
(
position
,
speed
,
forces
/
mass
,
dt
);
if
(
speed
>
0
&&
speed
<=
sq_speed_zero
)
speed
.
null
();
forces
.
null
();
}
double
NewtonDescriptor
::
getMass
()
const
{
return
mass
;
}
const
SVector
<
3
>&
NewtonDescriptor
::
getPosition
()
const
{
return
position
;
}
const
SVector
<
3
>&
NewtonDescriptor
::
getSpeed
()
const
{
return
speed
;
}
const
SVector
<
3
>&
NewtonDescriptor
::
getForces
()
const
{
return
forces
;
}
void
NewtonDescriptor
::
setMass
(
const
double
&
mass
)
{
this
->
mass
=
mass
;
}
void
NewtonDescriptor
::
setPosition
(
const
SVector
<
3
>&
position
)
{
this
->
position
=
position
;
}
void
NewtonDescriptor
::
setSpeed
(
const
SVector
<
3
>&
speed
)
{
this
->
speed
=
speed
;
}
void
NewtonDescriptor
::
setForces
(
const
SVector
<
3
>&
forces
)
{
this
->
forces
=
forces
;
}
void
NewtonDescriptor
::
operator
+=
(
const
SVector
<
3
>&
v
)
{
forces
+=
v
;
}
void
NewtonDescriptor
::
operator
+
(
const
SVector
<
3
>&
v
)
{
(
*
this
)
+=
v
;
}
void
NewtonDescriptor
::
operator
-=
(
const
SVector
<
3
>&
v
)
{
forces
-=
v
;
}
void
NewtonDescriptor
::
operator
-
(
const
SVector
<
3
>&
v
)
{
(
*
this
)
-=
v
;
}
Event Timeline
Log In to Comment