16 float x = (float)str.
x / 32767.0;
17 float y = (
float)str.
y / 32767.0;
18 float z = (float)str.
z / 32767.0;
19 float dx = (
float)str.
dx / 32767.0;
20 float dy = (float)str.
dy / 32767.0;
21 float dz = (
float)str.
dz / 32767.0;
65 string addr_recieved_from;
66 unsigned short port_recv_from;
67 char * request_command =
"send";
72 sock.
recvFrom(&received_data,
sizeof(received_data), addr_recieved_from, port_recv_from);
74 received_data.
x = ntohl(received_data.
x);
75 received_data.
y = ntohl(received_data.
y);
76 received_data.
z = ntohl(received_data.
z);
77 received_data.
dx = ntohl(received_data.
dx);
78 received_data.
dy = ntohl(received_data.
dy);
79 received_data.
dz = ntohl(received_data.
dz);
91 : source(&s), current_move_type(
kStopped),
92 bounce_distance(1.0), current_trace_index(0), trace_length(0) { };
95 : source(NULL), current_move_type(
kStopped),
96 bounce_distance(1.0), current_trace_index(0), trace_length(0) { };
125 #define signof(x) (((x)<0)? -1.0 : 1.0)
137 bounce_velocity.
x = -bounce_velocity.x;
139 bounce_velocity.y = -bounce_velocity.y;
141 bounce_velocity.z = -bounce_velocity.z;
172 cerr <<
"PMESource:: push_trace() - Trace full!" << endl;
181 #define RMAX (1.0) // meters
186 a = -0.5 *
mu / ((v*v*0.5) - (
mu / r) );
189 i = acos(h.
z / h.
len() );
209 e = fabs(rtemp * vtemp);
210 e = (
e<0.99) ?
e:0.99;
215 double error = 100.0;
219 while (c++ < 200000) {
224 rtemp *= (vs*vs - (
mu/r));
226 e_vec = rtemp - vtemp;
229 double old_error =
error;
231 delta = error - old_error;
234 cout <<
"Delta == 0" << endl << endl;
238 if (fabs(error) < (0.0001 *
e))
245 cout <<
"e:\t" <<
e << endl;
246 cout <<
"error:\t" << error << endl;
258 double r = (
a * (1.0 -
e*
e)) / (1.0 +
e * cos(
nu));
261 newPosition.
z = r * (sin(
nu+
w)*sin(
i) );
266 double E = acos((
e+cos(
nu)) / (1.0+
e*cos(
nu)) );
269 double M = E -
e*sin(E);
276 while (fabs(error) > 0.0001){
281 nu = acos((cos(E) -
e) / (1.0 -
e*cos(E)) );
289 cout <<
"Orbit:"<< endl;
290 cout <<
"semi-major axis:\t" <<
a << endl;
291 cout <<
"eccentricity:\t" <<
e << endl;
292 cout <<
"inclination angle:\t" <<
i << endl;
293 cout <<
"longitude of ascending node:\t" <<
omega << endl;
294 cout <<
"argument of perigee:\t" <<
w << endl;
295 cout <<
"true anomaly:\t" <<
nu << endl;
296 cout <<
"mean motion:\t" << sqrt(
mu / (
a*
a*
a) ) << endl;
297 cout <<
"mu:\t\t\t" <<
mu << endl << endl;
300 PME::PME (
string remote_net_addr,
unsigned short remote_port)
301 : controller(remote_net_addr, remote_port), grabbed_source(NULL), num_sources(0) {
307 : grabbed_source(NULL), num_sources(0) {
322 printf(
"Max number of VBAP sources exceeded. Source not added\n");
330 #define MIN_GRAB_DISTANCE_SQ (0.05)
345 struct timeval start, end;
360 cout <<
"grabbed source"<<endl;
370 cout <<
"making trace" << endl;
375 cout <<
"glove released" << endl;
397 struct timeval *s = &start, *e = &end;
COORD_TYPE distance2(CPoint *)
void set_current_move_type(MovementType mov_type)
void set_bounce_velocity(CPoint bv)
#define MIN_GRAB_DISTANCE_SQ
PMESource * grabbed_source
void update_grabbed_position(CPoint &p)
void calculate_eccentricity(CPoint R, CPoint V)
void set_orbit(CPoint &R, CPoint &V)
bool add_pme_source(PMESource &s)
void get_data(CPoint &p, CPoint &v, GloveState &glove_st)
void set_data(controller_str &str)
void calculate_orbital_params(CPoint R, CPoint V)
int recvFrom(void *buffer, int bufferLen, string &sourceAddress, unsigned short &sourcePort)
Temp Spatial Sound Source.
unsigned short num_sources
#define SUB_TIMES(t1, t2)
void push_trace(CPoint &pos)
void calculate_new_position_in_orbit()
MovementType get_next_move_type()
unsigned short foreign_port
void sendTo(const void *buffer, int bufferLen, const string &foreignAddress, unsigned short foreignPort)
double kTwoPi
PME.h – Ventriloquist See the copyright notice and acknowledgment of authors in the file COPYRIGHT D...
#define MAX_NUM_VBAP_SOURCES
VBAP.h – Vector Base Amplitude Panning class (v2 - Nov 2006) See the copyright notice and acknowledg...
MovementType current_move_type
CPoint trace[MAX_TRACE_LENGTH]
unsigned current_trace_index
MovementType next_move_type
void start_management_thread()
void stop_management_thread()
virtual void setPosition(CPoint pos)
Set the sound source position in cartesian coordinates.
int createThread(VoidFcnPtr *func, void *args)
void set_position(CPoint &P)
bool sleepUsec(float dur)
Misc. global functions in the csl namespace.
PMESource ** pme_source_list
void get_position(CPoint &p)
void set_bounce_distance(float bd)
bool keep_processing_sources
bool check_for_grabbed_source(CPoint &p)
void error(int num, const char *m, const char *path)
void set_next_move_type(MovementType mov_type)
string foreign_net_address
MovementType get_current_move_type()
void calculate_absolute_position(CPoint &new_position)
static void * management_func(void *data)
csl::ThreadPthread management_thread