Ejemplo n.º 1
0
//using the sine table, we return cosine by adding 90 degrees from the sine
float getCos(unsigned int val, TABLES *tab)
{
	if(val < 270)
	{
		return getSin(val+90, tab);
	}else
	{
		return getSin(val-270, tab);
	}
	return cos(val); //if value is out of range, we do a live (slower) cosine calculation
}
Ejemplo n.º 2
0
void Camera::move(int direction){// direction = 1 to front, direction = -1 to backwards
	i[0] += speed * direction * getCos();
	i[1] += speed * direction * d[1];
	i[2] += speed * direction * getSin();
	refreshDirection();
	refreshLookAt();
}
Ejemplo n.º 3
0
Archivo: body.cpp Proyecto: teqwve/nge
void Body::applyForce(Vec2 f, Point p) {
    if (length(f) == 0)
        return;
    if (p != getMassCenter() && !fixedAngle) {
        Vec2 n = getMassCenter()-p;
        force += getOrientedVec(n, length(f)*getCos(f, n));
        momentium += getSin(f,n)*length(f)*distance(p, getMassCenter());
    } else {
        force += f;
    }
}
Ejemplo n.º 4
0
	void update() {

		position[3][0] = distance * getCos();
		position[3][2] = distance * getSin();

		rotation = rotate(glm::mat4(), (float)(-glutGet(GLUT_ELAPSED_TIME) * 0.025f * orbitRadians * SPEED), glm::vec3(0.0f, 1.0f, 0.0f));

		orientation = position * rotation;
		
		return;

	}
Ejemplo n.º 5
0
int getCurrentSinValue(void){
	static uint8_t state = GETXSIN;
	int sinval;

	switch(state){
		case GETXSIN:
			slopepos_current = slopepos[sinindex];
			sinval = (int)getSin(sinpos_current = sinpos[sinindex])+xoffs;
			break;
		case GETYSIN:
			sinval = (int)getCos(sinpos_current)+yoffs;
		default: break;
	}
	/*if (NOSINSTATE == ++state){
		state = GETXSIN;
	}*/
	//only two states. toggle them
	state ^= 1;

	return sinval;
}
Ejemplo n.º 6
0
DSPFLOAT	SinCos::getSin (DSPFLOAT Phase) {
	if (Phase < 0)
	   return -getSin (- Phase);
	return imag (Table [fromPhasetoIndex (Phase)]);
}
Ejemplo n.º 7
0
void Camera::refreshDirection(){
	d[0] =  getCos() + i[0];
	d[2] =  getSin() + i[2];
}