Skip to content

Instantly share code, notes, and snippets.

View hiroyuki's full-sized avatar

hiroyuki hori - horristic hiroyuki

View GitHub Profile
round=lambda x:(x*2+1)//2
@hiroyuki
hiroyuki / WorkerThread
Created February 13, 2020 01:20
atomic release aquire simple study in openFrameworks
#pragma once
#include "ofMain.h"
class WorkerThread : public ofThread
{
public:
bool pinpon = false;
atomic_bool isFrameNew;
int value = 0;
void threadedFunction()
{
@hiroyuki
hiroyuki / BadSim.h
Last active June 18, 2019 09:02
badminton simlate
#pragma once
#include "ofMain.h"
class BadSim
{
public:
const float mass = 5.19;
const float grav = 9.80665;
const float terminal_velocity = 6.7;
float scale = 30; // 30 pix == 1m
@hiroyuki
hiroyuki / noise.frag
Created April 12, 2017 06:00
noise generate by GLSL
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
//
// fragment shader
#version 150
// this is how we receive the texture
uniform sampler2D tex0;
in vec2 varyingtexcoord;
out vec4 outputColor;
void main()
{
@hiroyuki
hiroyuki / scaling image with anchor point
Created May 2, 2013 09:37
scaling image with anchor point
void testApp::setup()
{
img.loadImage("history.png");
ofSetWindowShape(img.getWidth(), img.getHeight());
scale = 1.0;
}
void testApp::update()
{
@hiroyuki
hiroyuki / .gitignore
Last active December 14, 2015 06:59
horristic gitignore (windows VS added)
*.mov
*.jpg
*.aif
*.mpeg
*.exe
*.exp
*.ilk
*.pdb
*.lib
*.otf
@hiroyuki
hiroyuki / gist:3827613
Created October 3, 2012 15:34
Point inside the polygon
//http://alienryderflex.com/polygon/
bool tricks::math::pointInsidePolygon(ofVec2f &p, const vector<ofVec2f> &polygon, int resolution){
int counter = 0;
int i;
double xinters;
ofVec2f p1,p2;
float x = p.x;
float y = p.y;
@hiroyuki
hiroyuki / gist:3781210
Last active January 18, 2019 08:26
cartesian<>Polar
/**
* converts cartesion to polar coordinates
* result:
* [0] = length
* [1] = angle z-axis rotation [-PI, PI](range) Z軸回転
* [2] = angle of projection into x,y, plane with x-axis [-PI, PI](range)
*/
static ofVec3f cartesianToPolar(const ofVec3f &v)
{
ofVec3f polar;
@hiroyuki
hiroyuki / CRC
Created August 23, 2012 03:21
CRC16 encode/check
bool checkCrc()
{
u_short crc = BCapMessage::getMemCRC16( 0xffff, (u_char *)receivedData, 1, message_length - 3 );//add CRC by horristic
bool result = (receivedData[ message_length - 2 ] << 8) + receivedData[ message_length - 3 ] == crc;
return result;
}
static u_short getMemCRC16( unsigned short crc16, unsigned const char buff[], unsigned const short from, unsigned const short to )
{
int i;
unsigned short CRC16Table[ 256 ] = {