This file contains 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
public static float constrainAngle180(float angle) { | |
while (angle > 180) { | |
angle = angle - 360; | |
} | |
while (angle < -180) { | |
angle = angle + 360; | |
} | |
return angle; | |
} |
This file contains 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
void steerToDesiredFacing() { | |
if (desiredFacing == null) { | |
return; | |
} | |
float facing = getForwardFacing(); | |
// this contrain method keeps the angle between 180 and -180 | |
float diff = constrainAngle180(facing - desiredFacing); | |
// steer within n degrees of desired facing, use this to control precision | |
float angularThreshold = 1; | |
float angularVel = body.getAngularVelocity(); |
This file contains 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
void seekWaypoint(Vector2 waypoint) { | |
Vector2 pos = body.getPosition(); | |
float dist = waypoint.dst(pos); | |
// you should set a threshold for arrival distance | |
// that is good enough to be considered "arrived" for your purposes | |
if (dist < arrivalThreshold) { | |
if (waypoints.contains(waypoint)) { | |
// if we are chasing a target, don't remove the waypoint upon reaching arrival distance | |
waypoints.remove(0); | |
waypoint = getCurrentWaypoint(); |
This file contains 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
private Vector2 getVelocityCorrectionSteerpoint(Vector2 waypoint) { | |
if (waypoint == null) { | |
return null; | |
} | |
Vector2 selfVel = body.getLinearVelocity().cpy(); | |
// if this is not a regular waypoint, but instead a point we should chase | |
// (like a moving enemy target) then we want to correct for the target's velocity as well | |
if (isChaseTargetPosition(waypoint)) { | |
// add target's velocity to the waypoint, so we can predict movement | |
Vector2 targVel = targetEntity.body.getLinearVelocity(); |
This file contains 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
# | |
# A fatal error has been detected by the Java Runtime Environment: | |
# | |
# SIGSEGV (0xb) at pc=0x00007f7e0ad30504, pid=10789, tid=140178498938624 | |
# | |
# JRE version: 7.0_21-b11 | |
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode linux-amd64 compressed oops) | |
# Problematic frame: | |
# C [libgdx64.so+0x23504] b2BlockAllocator::Allocate(int)+0x54 | |
# |
This file contains 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
float dragForce; | |
Vector2 appliedDrag = new Vector2(); | |
float dragAngle; | |
float p, A, Cd, v; // elements of the formula see wikipedia entry for Drag (physics) | |
/* | |
ρ is the density of the fluid, | |
v is the speed of the object relative to the fluid, | |
A is the cross-sectional area | |
Cd is the drag coefficient – a dimensionless number. | |
sample drag co-efficients (http://en.wikipedia.org/wiki/Drag_coefficient) |
This file contains 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
#!/usr/bin/python | |
# test memory info from a glances server | |
import xmlrpclib | |
import sys | |
if len(sys.argv) < 2: | |
print "Please give 'host:port' as argument" | |
sys.exit() | |
host = sys.argv[1] | |
print "Getting data from " + host |
This file contains 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
#!/usr/bin/python | |
__author__ = 'jrenner' | |
import random | |
import sys | |
""" | |
This script is useful for testing the autoUnit function. It is not guaranteed | |
to be the same as in glances.py. You may need to copy and paste the exact | |
code you want to test from glances.py |
This file contains 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
func getPixel(surface *sdl.Surface, x, y int) uint32 { | |
var bpp uint8 = surface.Format.BytesPerPixel | |
/* Here p is the address to the pixel we want to retrieve */ | |
var p *uint32 = *uint32(int(surface.Pixels) + y*int(surface.Pitch) + x*bpp) | |
return *p | |
return 1 /* shouldn't happen, but avoids warnings */ | |
} |
This file contains 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 <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int** count_chars(char *s) | |
{ | |
int **counts = (int**)malloc(256 * sizeof(int) * sizeof(char)); | |
int i; | |
for(i = 0; i < 256; i++) | |
{ |