Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
Removed drifting grating's local definition of pi
Browse files Browse the repository at this point in the history
  • Loading branch information
cstawarz committed May 2, 2011
1 parent 4e2520b commit c8cb093
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 29 deletions.
16 changes: 0 additions & 16 deletions DriftingGratingStimulus/DriftingGratingConstants.h

This file was deleted.

9 changes: 4 additions & 5 deletions DriftingGratingStimulus/DriftingGratingStimulus.cpp
Expand Up @@ -8,7 +8,6 @@
*/

#include "DriftingGratingStimulus.h"
#include "DriftingGratingConstants.h"
using namespace mw;

DriftingGratingStimulus::DriftingGratingStimulus(const std::string &_tag,
Expand Down Expand Up @@ -280,8 +279,8 @@ void DriftingGratingStimulus::drawFrame(shared_ptr<StimulusDisplay> display, int
//
// multiply by -1 so it the grating goes in the correct direction
double elapsed_seconds = (double)elapsed_time / (double)1000000;
const double phase = -1*(starting_phase->getValue().getFloat()*(M_DG_PI/180.) + speed->getValue().getFloat()*spatial_frequency->getValue().getFloat()*(2.*M_DG_PI)*elapsed_seconds);
const double direction_in_radians = direction_in_degrees->getValue().getFloat()*(M_DG_PI/180.);
const double phase = -1*(starting_phase->getValue().getFloat()*(M_PI/180.) + speed->getValue().getFloat()*spatial_frequency->getValue().getFloat()*(2.*M_PI)*elapsed_seconds);
const double direction_in_radians = direction_in_degrees->getValue().getFloat()*(M_PI/180.);
const double aspect = width->getValue().getFloat()/height->getValue().getFloat();

//mprintf("drifting grating draw (%lld - %lld = %lld, %g, %g, %g, %g)", now, start_time, elapsed_time, elapsed_seconds, phase, direction_in_radians, aspect);
Expand All @@ -297,7 +296,7 @@ void DriftingGratingStimulus::drawFrame(shared_ptr<StimulusDisplay> display, int
const float mask_s_ratio = 1-MIN(1,aspect);
const float mask_t_ratio = 1-MIN(1,1/aspect);

const float phase_proportion = phase/(2*M_DG_PI);
const float phase_proportion = phase/(2*M_PI);
const float cycle_proportion = spatial_frequency->getValue().getFloat()*width->getValue().getFloat();

glNormal3f(0.0, 0.0, 1.0);
Expand All @@ -320,7 +319,7 @@ void DriftingGratingStimulus::drawFrame(shared_ptr<StimulusDisplay> display, int

glEnd(); // GL_QUADS

last_phase = phase*(180/M_DG_PI);
last_phase = phase*(180/M_PI);


// ----------------------------------------
Expand Down
Expand Up @@ -80,7 +80,6 @@
0EC0F2CA0EC533E8004AD5CE /* GratingData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GratingData.h; sourceTree = "<group>"; };
0EC0F2D10EC53519004AD5CE /* SinusoidGratingData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinusoidGratingData.h; sourceTree = "<group>"; };
0EC0F2D20EC53519004AD5CE /* SinusoidGratingData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SinusoidGratingData.cpp; sourceTree = "<group>"; };
0EC0F2EA0EC53788004AD5CE /* DriftingGratingConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DriftingGratingConstants.h; sourceTree = "<group>"; };
0EC0F33A0EC5395C004AD5CE /* SquareGratingData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SquareGratingData.h; sourceTree = "<group>"; };
0EC0F33B0EC5395C004AD5CE /* SquareGratingData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SquareGratingData.cpp; sourceTree = "<group>"; };
0EDCBABE0EE9D39B00432792 /* MWLibrary.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = MWLibrary.xml; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,7 +152,6 @@
0EC0F2540EC52DD7004AD5CE /* Factory */,
0EC0F2350EC52B22004AD5CE /* Masks */,
0EC0F2C90EC533CA004AD5CE /* Textures */,
0EC0F2EA0EC53788004AD5CE /* DriftingGratingConstants.h */,
0EE4686B0ECCB6DC00C4CDE7 /* DriftingGratingUtilities.h */,
0EE4686C0ECCB6DC00C4CDE7 /* DriftingGratingUtilities.cpp */,
);
Expand Down
3 changes: 1 addition & 2 deletions DriftingGratingStimulus/GaussianMask.cpp
Expand Up @@ -8,7 +8,6 @@
*/

#include "GaussianMask.h"
#include "DriftingGratingConstants.h"

mGaussianMask::mGaussianMask(const shared_ptr<Variable> &_size,
const shared_ptr<Variable> &_mean,
Expand All @@ -21,7 +20,7 @@ mGaussianMask::mGaussianMask(const shared_ptr<Variable> &_size,
// for clarity
const float s = std_dev->getValue().getFloat();
const float u = mean->getValue().getFloat();
const float pi = M_DG_PI;
const float pi = M_PI;

// leave the one pixel margin around the edge
for(unsigned int channel=0; channel<M_MASK_CHANNELS; ++channel) {
Expand Down
3 changes: 1 addition & 2 deletions DriftingGratingStimulus/SinusoidGratingData.cpp
Expand Up @@ -8,13 +8,12 @@
*/

#include "SinusoidGratingData.h"
#include "DriftingGratingConstants.h"


mSinusoidGratingData::mSinusoidGratingData(const shared_ptr <Variable> &_data_sample_rate) : mGratingData(_data_sample_rate) {
for(unsigned int i=0; i<current_data_size; ++i) {
// use cos so it matches other gratings
data[i] = 0.5*(1+cos(2*M_DG_PI*i/current_data_size));
data[i] = 0.5*(1+cos(2*M_PI*i/current_data_size));
}
}

Expand Down
3 changes: 1 addition & 2 deletions DriftingGratingStimulus/SquareGratingData.cpp
Expand Up @@ -8,13 +8,12 @@
*/

#include "SquareGratingData.h"
#include "DriftingGratingConstants.h"


mSquareGratingData::mSquareGratingData(const shared_ptr <Variable> &_data_sample_rate) : mGratingData(_data_sample_rate) {
for(unsigned int i=0; i<current_data_size; ++i) {
// use cos so it matches other gratings
data[i] = cos(2*M_DG_PI*i/current_data_size) > 0 ? 1 : 0;
data[i] = cos(2*M_PI*i/current_data_size) > 0 ? 1 : 0;
}
}

Expand Down

0 comments on commit c8cb093

Please sign in to comment.