Skip to content

Instantly share code, notes, and snippets.

let x(t) = distance from dest on x
let y(t) = distance from dest on y
let z(t) = distance from dest on z
let r(t)^2 = x(t)^2 + y(t)^2 + z(t)^2
let f(t) = force
x(0) initial condition
y(0) initial condition
z(0) initial condition
f(t)
a(0)
b(0)
a(t) = (b(t) - a(0))t + a(0)
b(t) = (a(t) - b(0))t + b(0)
a(t) = (((a(t) - b(0))t + b(0)) - a(0))t + a(0)
a(t) = t^2 (a(t) - b(0)) + t (b(0) - a(0)) + a(0)
Assumptions: Start at 0, time = t goes from 0 to 1
let b = end of move action
let c = end of 1st SetPoint3Action
let d = end of 2nd SetPoint3Action
let e = end of 3rd SetPoint3Action
let d(t) = (e-d)t + d
let c(t) = (d(t) - c)t + c
let b(t) = (c(t) - b)t + b
let a = start position
let b = end position
p(t) = (b-a)t + a
let d = SetMove3Action's end point
p(t) = ((d-b)t+b)t + a = (dt - bt + b)t + a = (d-b)t^2 + bt + a
let d = 0, then p(t) = -bt^2 + bt + a
@Sgeo
Sgeo / SOs.json
Created October 18, 2019 04:07
X_ITE SharedObjects
[
{
"name": "5000 EXP Trophy",
"id": "5000exp",
"url": "/dbobjects/5000/5000exp.wrl",
"position": {"x": 0.0, "y": 1.75, "z": 0.0},
"rotation": {"x": 0.0, "y": 1.0, "z": 0.0, "angle": 0.0}
}
]
@Sgeo
Sgeo / fixgray.js
Last active October 2, 2019 04:50
// This code is NOT spec compliant: An RGB texture can be mistaken for an intensity texture if all its pixels happen to be gray.
// I suspect this will not particularly affect a lot of textures, but it is a possibility
// This also needs to check all URLs rather than the first, preferably the same way X3DOM does if possible
// Also better error handling
function fixGray(imageTexture) {
var url = imageTexture.getFieldValue("url")[0];
var img = new Image();
@Sgeo
Sgeo / DNA.cpp
Created August 9, 2019 04:48
Source code for Langton's loops CA in MCell
/* DNA.cpp
*
* This automata was designed by Christopher G. Langton at the University
* of Michigan, and is described in his article "Self-Reproduction in
* Cellular Automata", published in the book "Cellular Automata" in 1984.
*
* As described in the above article, this automata is "realistic" and
* "non-trivial", in the following ways:
*
* The reproduction is not simply due to the particular rules used in
#include <stdio.h>
#include <stdarg.h>
#include <dos.h>
#include <i86.h>
#include <conio.h>
#include "vfx1.h"
extern unsigned _psp;
unsigned __far *psp_pointer;
unsigned _get_memsize();
@Sgeo
Sgeo / CONVERT.C
Created June 20, 2019 23:20
Part of convert.c in the i-Glasses SDK. Note that "raw" should be called "cooked". An emulator needs to reverse this math.
void rawToEulerInt(long rawMagneticX,long rawMagneticY,long rawMagneticZ,
long rawGravimetricX,long rawGravimetricY,
long * eulerYaw,long * eulerPitch,long * eulerRoll) {
vec3 rotMagnetic;
vec2 linGravimetric;
vec2 normRotMag;
sinCos pitch,roll;
#ifdef USE_FILTERS
if (!madeFilters) {
def prim(name, default, actions):
action_string = ", ".join(actions)
if default:
animate_string = ", animate me . 1 1 0"
else:
animate_string = ""
print("create name %s%s; adone %s" % (name, animate_string, action_string))
def action_prim_mem(name, value):
action_string = "animate %s . 1 1 %s" % (name, ("0" if value else "2147483647"))