Skip to content
View VectorMath.java
// Only scalar values, both for parameters and return values.
// Calculation must be split into 2 methods. Ugly code, duplicate calculations.
public final class VectorMath {
public static double getRotatedX(final double x, final double y,
final double angle) {
return x * Math.cos(angle) - y * Math.sin(angle);
}
View Main.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.Box;
View after-aab22
Running Ball Drop
Ball Drop (10 steps, 10 solve loops) : 27 ms (370.3703703703704 steps/second)
Checksum: -1.8194444444444444
Ball Drop (10 steps, 30 solve loops) : 10 ms (1000.0 steps/second)
Checksum: -1.8194444444444444
Ball Drop (100 steps, 10 solve loops) : 39 ms (2564.102564102564 steps/second)
Checksum: -30.69444444444442
View with vector_math
Running Ball Drop
Ball Drop (10 steps, 10 solve loops) : 23 ms (434.7826086956522 steps/second)
Checksum: -1.8194442838430405
Ball Drop (10 steps, 30 solve loops) : 9 ms (1111.111111111111 steps/second)
Checksum: -1.8194442838430405
Ball Drop (100 steps, 10 solve loops) : 42 ms (2380.9523809523807 steps/second)
Checksum: -30.694456100463867
View gist:4011883
#lang racket
(define (anfangskurs A B D)
(define alpha (my-acos (/ (- (sin B) (* (cos D) (sin A))) (* (cos A) (sin D)))))
(cond
[(< 180 alpha) (- 360 alpha) alpha]))
View degree.rkt
#lang racket
(define (degree->cardinal degree)
(case (modulo (inexact->exact (round (* 32 (/ degree 360)))) 32)
((0) "N")
((1) "NbE")
((2) "NNE")
((3) "NEbN")
((4) "NE")
((5) "NEbE")
View degree->name
#lang racket
(define (helper dir1 dir2 sub)
(cond
[(= sub 1) dir1]
[(= (modulo sub 4) 0) (string-append "b" dir1)]
[(= (modulo sub 2) 0) (string-append "b" dir2)]
))
(define directions "NESESWNW")
View gist:3941116
#lang racket
(define (degree->radian degree)
(* (/ (* 2 pi) 360) degree))
(define (radian->degree radian)
(* (/ 360 (* pi)) radian))
(define (my-acos alpha)
(if (= alpha 0)
View trait.php
<?php
/**
* Is this possible in php5.4 using traits?
*/
trait Hashmap {
public function set($key, $val) {
$this->data[$key] = $val;
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
Something went wrong with that request. Please try again.