void USSensor::updateValue(double curAngle, Point currentPosition, Map *map) { double sensorAngle = fmod(curAngle + this->angle + 2*PI, 2*PI); Line sensorLine = getSensorLine(currentPosition, sensorAngle); double distance = INFINITY; for (std::vector<LineSegment>::iterator it = map->lines.begin(); it != map->lines.end(); ++it) { LineSegment segment = *it; distance = checkSegment(segment, sensorLine, sensorAngle, currentPosition, distance); } LineSegment bombSegments[4]; map->bomb.getLineSegments(bombSegments); for (int i = 0; i < 4; i++) { LineSegment segment = bombSegments[i]; distance = checkSegment(segment, sensorLine, sensorAngle, currentPosition, distance); } //printf("Sensor %d updated to value %f\n", this->num, distance); this->value = distance; }
int main(int argc, char** argv) { FILE *f = fopen(argv[1], "r"); if(argc != 2 || f == NULL) { printf("Usage: %s FILE\n", argv[0]); return 1; } int output = checkSegment(f, EOF); if(output != 0) printf("There was an error!\n"); return output; }