Skip to content

Instantly share code, notes, and snippets.

View SharpCoder's full-sized avatar
🛰️
inventing

Josh Cole SharpCoder

🛰️
inventing
View GitHub Profile
@SharpCoder
SharpCoder / silly.ts
Created March 1, 2025 03:04
Silly Typscript is Silly
export class TRS {
/** x transform */
x: number;
/** y transform */
y: number;
/** x scale */
sx: number;
/** y scale */
sy: number;
/** x rotation offset */
@SharpCoder
SharpCoder / example.ts
Last active February 27, 2025 01:39
Matrix example
const result = m4.combine([
m4.translate(x,y,z),
m4.rotateX(rads(35)),
m4.rotateY(rads(25)),
])
// Here's how you can decompose the result back into a vector
const vector = [
result[6],
result[7],
@SharpCoder
SharpCoder / README.md
Last active January 15, 2025 07:24
Shamos and Hoey Intersection Algorithm (Naiive)

Shamos and Hoey Polygon Intersection Algorithm

This is my very horrific attempt to implement the Shamos and Hoey intersection algorithm. The algorithm is defined in the paper Geometric Intersection Problems (1976).

Thoughts

  • For the love of god, don't re-sort the array each time you insert. There's gotta be an O(n) way to do it???
  • Verify the algorithm more (I don't actually know if it's correct)
  • Next, implement the Bently and Ottmann optimizations
@SharpCoder
SharpCoder / README.md
Last active November 24, 2024 23:36
ChronoPixel API Specification v1.0

ChronoPixel API Specification

This gist outlines the specification for the ChronoPixel v1.0 scripting library. The goal is to approximate similar functionality as found in Macromedia Flash (from ye olde web). The language of choice for ChronoPixel will be LUA. Code will be interpreted at runtime while manipulation of the world will happen via javascript bindings which hook in to the ChronoPixelMX source engine.

ChronoPixel Scripting V1 Specification

Scope

@SharpCoder
SharpCoder / infra-stack.js
Created October 28, 2023 16:09
Express server in fargate with cdk
const {
aws_route53: route53,
aws_certificatemanager: acm,
aws_ecs: ecs,
aws_ec2: ec2,
aws_ecr_assets: ecr_assets,
aws_elasticloadbalancingv2: elbv2,
Stack,
CfnOutput,
IgnoreMode,
@SharpCoder
SharpCoder / README.md
Last active August 29, 2023 00:39
A 2D (XY) robotic platform

A 2D (XY) Robotic Platform

Here are the files for my 2d robotic platform. Each file is meant to be fabricated on a 3d printer (except the assembly.scad file, which is really just a visualization for the final build).

@SharpCoder
SharpCoder / logic.ts
Last active March 24, 2023 14:48
Sphere/Cuboid Collision
function getAABB(rect: Cuboid) {
const result = {
min: [rect.x, rect.y, rect.z],
max: [rect.x + rect.w, rect.y + rect.h, rect.z + rect.d],
};
// Swap the vertices if the min/max is reversed
// because of orientation or whatever.
for (let i = 0; i < 3; i++) {
if (result.max[i] < result.min[i]) {
@SharpCoder
SharpCoder / problem.md
Last active March 6, 2023 16:01
Absolute Orientation Problem

Absolute Orientation Problem

This project is all about calculating the position of a telescope. I derive absolute orientation using a magnetometer sensor and accelerometer sensor. By absolute orientation, I mean deriving the euler angles of the telescope. The root problem I'm facing is that the yaw reading experiences a mostly linear error after pitching the device beyond a specific threshold. (About 50 degrees or so).

Reproducing the Problem

To consistently observe the error, a simple experiment can be performed which reliably yields the problem.

Experiment

@SharpCoder
SharpCoder / math.rs
Last active February 8, 2023 16:21
Space Math in Rust
#![allow(unused)]
use chrono::prelude::*;
use std::f64::consts::PI;
type Float = f64;
#[derive(Copy, Clone)]
pub struct GpsCoordinate {
pub latitude: Angle,
@SharpCoder
SharpCoder / grate.scad
Created January 17, 2023 16:10
Grate for zenith space command controller
SPACING = 1.5;
W = 25;
H = 100;
module grate(W, H, SPACING) {
for (i = [0:W/SPACING/2]) {
translate([(SPACING * 2 * i) - ((W-SPACING)/2), 0, 0])
square([SPACING, H], center=true);
}
}