This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
[email protected] | |
Tool to test collision detection using Grapher.app | |
Create formatted data. | |
Input: cd.in | |
0.000000 320.000000 194.204971 -60.418026 244.204971 -10.418026 | |
0.000000 320.000000 194.249619 -60.418026 244.249619 -10.418026 | |
0.000000 320.000000 194.294266 -60.418026 244.294266 -10.418026 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test for two line segments intersection | |
// [email protected] | |
// Inspired from: | |
// theory: http://www.bryceboe.com/2006/10/23/line-segment-intersection-algorithm/ | |
// source: http://www.bryceboe.com/wordpress/wp-content/uploads/2006/10/intersect.py | |
#include <iostream> | |
template<typename T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <cstring> | |
bool debug; | |
bool isFactor(long double n, long double f){ | |
long double i = 1.0; | |
long double m = f * i; | |
while(m <= n){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
What: Exception using throw and jmp/longjmp | |
Author: Sid | |
Note: Test run with 3 cases | |
1: x(10), y(2) : Returns 2 | |
2: x(10), y(0) : Catch exception DIVIDE_EXCP, prints error and quit | |
3: x(10), y(-2) : Catch exception NEG_EXCP, does nothing | |
*/ | |
#include <iostream> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SJViewController.m | |
// TestSkybox | |
// | |
// Created by Sidharth Juyal on 22/06/12. | |
// Copyright (c) 2012 whackylabs. All rights reserved. | |
// | |
#import "SJViewController.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This piece of shit that I wrote does one simple task: linearly interpolate between 0.0 and 1.0 for the value 'res'. | |
This is a sample run: | |
$ ./mix 1 | |
0: 0.500000 | |
$ ./mix 2 | |
0: 0.333333 | |
1: 0.666667 | |
$ ./mix 3 | |
0: 0.250000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Electricity: | |
resolution_ = 0; means straight line | |
pointA_, pointB_; are vec4s | |
*/ | |
void ElectricCurrent::createVertexData(){ | |
int tfloats = (2+resolution_) * 4; //num_points * num_floats_per_point | |
GLfloat data[tfloats]; | |
int atIndx = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main (int argc, const char * argv[]){ | |
// Create the main window | |
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window"); | |
// Load a sprite to display | |
sf::Texture texture; | |
if (!texture.loadFromFile(resourcePath() + "cute_image.jpg")) | |
return EXIT_FAILURE; | |
sf::Sprite sprite(texture); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
At create setup stage | |
*/ | |
glEnableVertexAttribArray(GLKVertexAttribPosition); | |
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0)); | |
glEnableVertexAttribArray(GLKVertexAttribNormal); | |
glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12)); | |
/* | |
At binding stage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(troop_position == 4){ | |
for(int possible_position = 0; possible_position < 9; possible_position++){ | |
if(_slots[possible_position] == -1){ | |
availPos[troop_number][available_position[troop_number]++] = possible_position; | |
} | |
} | |
}else{ | |
for(int possible_position = 0; possible_position < 3; possible_position++){ | |
if(_slots[_nextPossiblePositions[troop_position][possible_position]] == -1){ | |
availPos[troop_number][available_position[troop_number]++] = _nextPossiblePositions[troop_position][possible_position]; |