Skip to content

Instantly share code, notes, and snippets.

View jjrv's full-sized avatar

Juha Järvi jjrv

View GitHub Profile
@jjrv
jjrv / LICENSE
Created August 19, 2015 14:38
Fast exact integer perp dot product sign in JavaScript
The MIT License (MIT)
Copyright (c) 2015 BusFaster Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jjrv
jjrv / LICENSE
Created August 20, 2015 14:50
Counting sign changes without branching
The MIT License (MIT)
Copyright (c) 2015 BusFaster Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jjrv
jjrv / run.ts
Created November 13, 2015 14:41
import {hello} from './src/test';
hello();
@jjrv
jjrv / README.md
Last active December 9, 2016 18:45
Presentation about nbind usage and structure
@jjrv
jjrv / config.js
Last active September 27, 2017 06:39
System.config({
transpiler: false,
map: {
dstore: 'node_modules/dojo-dstore',
css: 'node_modules/systemjs-plugin-css/css.js'
},
packages: {
'node_modules/dojo/': {
{
"private": true,
"name": "classy-test",
"scripts": {
"install": "cd node_modules && git clone https://github.com/charto/classy-mst.git && cd classy-mst && git checkout develop && tsc -d --outdir dist src/index.ts src/classy-mst.ts",
"test": "tsc && mocha"
},
"license": "MIT",
"devDependencies": {
"@types/mocha": "^2.2.47",
import { Widget } from '@phosphor/widgets';
import { ElementExt } from '@phosphor/domutils';
export class IframePanel extends Widget {
constructor(iframe?: HTMLIFrameElement | null) {
super({ node: IframePanel.createNode() });
if(!iframe) iframe = document.createElement('iframe');
this.iframe = iframe;
@jjrv
jjrv / vtable.zig
Last active October 31, 2023 15:32
const std = @import("std");
/// Given an example struct with methods, create a function that produces vtables for similarly shaped structs.
/// A vtable contains function pointers to all the struct methods, with the struct type erased.
/// All structs should have an init function that takes an allocator as the first parameter and stores it in a field called "allocator".
/// At most 2 parameters are supported for methods (in addition to the initial self parameter).
pub fn VTableShape(comptime Template: type) type {
var fields = @typeInfo(struct { //
deinit: *const fn (*anyopaque) void,
}).Struct.fields;

We want to find a perspective camera lookat direction $\hat{d}$ so that a given direction $\hat{a}$ in world coordinates becomes $\hat{b}$ in camera coordinates. The camera rotation matrix $R$ is defined by:

World local up vector:

$$ \hat{y} = \begin{bmatrix} 0 & 1 & 0 \end{bmatrix}^{\mkern-1.5mu\mathsf{T}} $$

Camera lookat vector: