Skip to content

Instantly share code, notes, and snippets.

View JPBotelho's full-sized avatar

JPBotelho JPBotelho

  • JPBotelho
  • Portugal
View GitHub Profile
@JPBotelho
JPBotelho / README.md
Created April 6, 2021 19:50 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
Gerstner Waves
2D Fluid Simulation
Knot Rendering
Ant Behaviour
Game of Life
import requests
import discord
from discord.ext import commands
import random
import json
headers = {
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
}
/* to map a cubemap into a texture atlas; bottom to top left to right */
float faceWidth;
float faceHeight;
float atlasWidth = faceWidth*3;
float atlasHeight = faceHeight*2;
for(int i = 0; i < 2; i++)
for(int z = 0; z < 3; z++)
//Based on explanation http://www.hiddendimension.com/fractalmath/Divergent_Fractals_Main.html
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 c = fragCoord.xy / iResolution.xy;
//scaling real axis to [-2.5, 1.5] and imaginary axis to [-1.5, 1.5]
c = c * vec2(4,3) - vec2(2.5, 1.5);
vec2 z = vec2(0);
fragColor = vec4(0);
@JPBotelho
JPBotelho / Celtic Mandelbar
Last active December 28, 2018 12:23
Celtic Mandelbar
//Based on explanation http://www.hiddendimension.com/fractalmath/Divergent_Fractals_Main.html
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 c = fragCoord.xy / iResolution.xy;
//scaling real axis to [-2.5, 1.5] and imaginary axis to [-1.5, 1.5]
c = c * vec2(4,3) - vec2(2.5, 1.5);
vec2 z = vec2(0);
fragColor = vec4(0);
private void OnTriggerEnter(Collider other)
{
Debug.Log("Collided with " + other.transform.name);
Vector3 rbVelocity = Actor.RigidbodyComp.velocity;
Vector3 direction = transform.position - GetComponent<Collider>().transform.position;
direction.Normalize();
Actor.RigidbodyComp.velocity = Vector3.zero;
Actor.RigidbodyComp.AddForce(-rbVelocity.normalized * force, ForceMode.Impulse);
@JPBotelho
JPBotelho / NewBehaviourScript.cs
Last active October 6, 2017 22:21
Unity Script Templates
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class NewBehaviourScript : MonoBehaviour
{
void Start ()
{
}
@JPBotelho
JPBotelho / DirectionFromEulerAngle
Last active September 28, 2017 20:00
A method that returns a direction from 2 Euler Angles.
// Y - Vertical
//XZ - Horizontal
public static Vector3 DirFromAngle (float xa, float ya)
{
float x = Mathf.Cos(xa * Mathf.Deg2Rad) * Mathf.Cos(ya * Mathf.Deg2Rad);
float y = Mathf.Sin(xa * Mathf.Deg2Rad);
float z = Mathf.Cos(xa * Mathf.Deg2Rad) * Mathf.Sin(ya * Mathf.Deg2Rad);
return new Vector3(x, y, z).normalized;
}