Skip to content

Instantly share code, notes, and snippets.

View mattatz's full-sized avatar
👁️‍🗨️
Yes

mattatz mattatz

👁️‍🗨️
Yes
View GitHub Profile

非破壊 TypeSctript

mizchi / TypeScript Meetup 2


About

  • mizchi / 竹馬光太郎
  • フロントエンドと Node.js
@sketchpunk
sketchpunk / b64_to_float32Array.js
Created September 1, 2017 03:08
Base64 String to Float32Array in Javascript, good for WebGL
var blob = window.atob("AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAA"), // Base64 string converted to a char array
fLen = blob.length / Float32Array.BYTES_PER_ELEMENT, // How many floats can be made, but be even
dView = new DataView( new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT) ), // ArrayBuffer/DataView to convert 4 bytes into 1 float.
fAry = new Float32Array(fLen), // Final Output at the correct size
p = 0; // Position
for(var j=0; j < fLen; j++){
p = j * 4;
dView.setUint8(0,blob.charCodeAt(p));
dView.setUint8(1,blob.charCodeAt(p+1));
@hanigamal
hanigamal / fine-intersect.cpp
Created September 13, 2013 21:47
Find the point of intersection of two 3D line segments, works in 2D if z=0
// Assume Coord has members x(), y() and z() and supports arithmetic operations
// that is Coord u + Coord v = u.x() + v.x(), u.y() + v.y(), u.z() + v.z()
inline Point
dot(const Coord& u, const Coord& v)
{
return u.x() * v.x() + u.y() * v.y() + u.z() * v.z();
}
inline Point