Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97184644
body.h
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
Fri, Jan 3, 06:21
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Jan 5, 06:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23348782
Attached To
rSTICAZZI yearII_reports
body.h
View Options
#ifndef __BODY_H__
#define __BODY_H__
#include <iosfwd>
#include "symbasic/dvector.h"
#include "symbasic/svector.h"
typedef
SVector
<
double
,
2
>
Vec2D
;
typedef
SVector
<
Vec2D
,
2
>
BodyCoords
;
typedef
DVector
<
BodyCoords
>
SysCoords
;
/* SysCoords structure
*
* Body 1:
* Speed: (Vx, Vy)
* Position: (x, y)
* Body 2:
* Speed: (Vx, Vy)
* Position: (x, y)
* ...
* Body n:
* Speed: (Vx, Vy)
* Position: (x, y)
*/
struct
Body
{
double
m
;
Vec2D
v
;
Vec2D
x
;
bool
fixed
;
const
Vec2D
&
position
()
const
{
return
x
;
}
const
Vec2D
&
velocity
()
const
{
return
v
;
}
const
BodyCoords
coordinates
()
const
{
return
BodyCoords
({
v
,
x
});
}
void
update
(
const
BodyCoords
&
entry
)
{
v
=
entry
[
0
];
x
=
entry
[
1
];
}
bool
isFixed
()
const
{
return
fixed
;
}
};
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
Vec2D
&
v
);
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
Body
&
body
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Body
&
body
);
#endif
Event Timeline
Log In to Comment