This is a test of an extended markdown syntax for use in my blog.
@more
.
@tags Code, Algorithms, Blog, CSS Tutorials @date 2012-02-02T18:20:00 GMT+9 @from 139.5, 9.88 "Yokohama, Japan"
V = sphere.center - cone.apex_location | |
a = V * cone.direction_normal | |
b = a * cone.tan | |
c = sqrt( V*V - a*a ) | |
d = c - b | |
e = d * cone.cos | |
now if ( e >= sphere.radius ) , cull the sphere | |
else if ( e <=-sphere.radius ) , totally include the sphere | |
else the sphere is partially included. |
V = sphere.center - cone.apex_location | |
a = dotProduct(V, cone.direction_normal) | |
p = a * cone_sin | |
q = cone_cos * cone_cos * dotProduct(V, V) - a*a | |
r = q - sphere_radius * sphere_radius | |
if ((p < sphere_radius) || (q > 0)) { | |
if (r < 2 * sphere_radius * p) | |
return -1; // Sphere and cone enveloppes intersect | |
else if (q < 0) |
V = sphere.center - cone.apex_location | |
a = dotProduct(V, cone.direction_normal) | |
x = cone.cos * sqrt(dotProduct(V,V) - a*a) - a*cone.sin | |
if (abs(x) > sphere.radius) { | |
if (x < 0) | |
return 1; // Sphere is totally included in cone | |
else | |
return 0; // Sphere and cone don't intersect at all | |
} |
#include <math.h> | |
/// Computes the sine and cosine of two angles | |
/// in: angles = Two angles, expressed in radians, in the [-PI,PI] range. | |
/// out: results = vector containing [sin(angles[0]),cos(angles[0]),sin(angles[1]),cos(angles[1])] | |
static inline void vsincos(const float angles[2], float results[4]) { | |
static const float constants[] = { | |
/* q1 */ 0, M_PI_2, 0, M_PI_2, | |
/* q2 */ M_PI, M_PI, M_PI, M_PI, | |
/* q3 */ 4.f/M_PI, 4.f/M_PI, 4.f/M_PI, 4.f/M_PI, |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
WIDE_MAP = dict((i, i + 0xFEE0) for i in xrange(0x21, 0x7F)) | |
WIDE_MAP[0x20] = 0x3000 | |
def widen(s): | |
""" | |
Convert all ASCII characters to the full-width counterpart. |
#include <cstdio> | |
#include <unistd.h> | |
#include <cstdlib> | |
#include <X11/Xlib.h> | |
#include <X11/extensions/xf86vmode.h> | |
#include <iostream> | |
using ::std::cerr; | |
using ::std::endl; | |
int main(void) { |
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller | |
// fixes from Paul Irish and Tino Zijdel and Julien Cayzac | |
(function() { | |
var lastTime = 0, | |
vendors = ['ms', 'moz', 'webkit', 'o'], | |
x, |