Skip to content

Commit

Permalink
collision debugging stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ndevenish authored and Nicholas Devenish committed Feb 21, 2011
1 parent 8b78230 commit 3869f6c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/veltest.nsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

add edmexperiment "Velocity Test Experiment" {
set phase_steps 30 #phase average loops
set bounces 10000 #number of bounces to run the simulation over
#set lifetime 60 #The lifetime of a particle (seconds)
# set bounces 10000 #number of bounces to run the simulation over
set lifetime 120 #The lifetime of a particle (seconds)

#Set the distance to 'lift' the particle off of the bottles
#surface after a collision has happened. This is in to fix
Expand Down Expand Up @@ -37,7 +37,7 @@ add edmexperiment "Velocity Test Experiment" {

#vary velocity from 10 to 200 in 20 steps
#set velocity 3 # (Meters per second)
#vary velocity from 1 to 500 in 40 steps
#vary velocity from 100 to 500 in 3 steps
set velocity 500
#This will 'spread out' the velocity to a random point on a
#maxwell-boltzmann distribution of velocities
Expand Down
23 changes: 22 additions & 1 deletion src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <string>
#include <assert.h>
#include <iostream>
#include <fstream>

#include <boost/thread/mutex.hpp>

#include "nslobject.h"
#include "nslobjectfactory.h"
Expand Down Expand Up @@ -279,7 +282,25 @@ void container::reflect ( vector3& velocity_vec, const vector3& normal, const lo
if (normal.z < 0)
velocity_vec.z *= -1.;
}

// Dump out the dot product between this and the normal
static std::ofstream dotps("dotps.txt");
static std::ofstream dotwrong("dotwrong.txt");
static std::ofstream reflects("reflects.txt");

{
static boost::mutex output_mutex;
boost::mutex::scoped_lock lock(output_mutex);

long double dotp = dot(velocity_vec / velocity, normal);

dotps << dotp << endl;

if (dotp < 0)
logger << "NEGATIVE DOT PRODUCT ON REFLECTION" << endl;
if (dotp > 1)
dotwrong << dotp << "\t(" << velocity_vec << ")\t(" << normal*velocity << ")" << endl;
reflects << velocity_vec << endl;
}
}
else
throw runtime_error("Unrecognised reflection type requested for reflection");
Expand Down

0 comments on commit 3869f6c

Please sign in to comment.