Skip to content

Instantly share code, notes, and snippets.

View RichardEllicott's full-sized avatar

Richard Ellicott RichardEllicott

  • Luton
View GitHub Profile
## using chat gp, asked for python (this gives an egg shape wtf?)
## https://chat.openai.com/c/0269574d-acb5-4f88-ac65-0a2c27e016df
static func get_keppler_position(semi_major_axis: float = 8.0, eccentricity: float = 0.9, theta: float = 0.0) -> Vector3:
var semi_minor_axis: float = semi_major_axis * sqrt(1.0 - eccentricity**2) # Calculate the semi-minor axis
var pos: Vector3 = Vector3(semi_major_axis * cos(theta), 0.0, semi_minor_axis * sin(theta))
var rotation_angle = atan2(pos.z, pos.x)
## this but from chat gp, it doesn't seem a pure rotation, it seems to transform the parametric to keppler
pos = Vector3(
import matplotlib.pyplot as plt
import numpy as np
def plot_kepler_orbit(semi_major_axis, eccentricity, num_points=1000):
# Calculate the semi-minor axis
semi_minor_axis = semi_major_axis * np.sqrt(1 - eccentricity**2)
# Generate theta values (angle from the positive x-axis)
theta = np.linspace(0, 2*np.pi, num_points)
@RichardEllicott
RichardEllicott / gist:359a80c386913ce33d5936b4f04f6007
Created November 9, 2023 17:19
get or create a node in Godot, stopped working some point in 4.1.x
## get existing or create new child node, works in tool mode to show in editor
static func get_or_create_child(_parent, _name, type = Node3D) -> Node:
var child = _parent.get_node_or_null(_name)
if not child:
child = type.new()
child.name = _name
_parent.add_child(child)
if Engine.is_editor_hint(): # if in editor we need to do this to show in editor
child.set_owner(_parent.get_tree().edited_scene_root) # new, allows static
return child
# function that takes array of Vector3, returns a spline between them (as a Curve3D)
static func spline_positions_to_curve(marker_positions: Array, curve_strength: float) -> Curve3D:
var curve3D: Curve3D = Curve3D.new()
for i in marker_positions.size():
var pos = marker_positions[i] # curve pos
"""
FINISHED 03/12/2022
HUGE drag drop modue, supports dragging cards about and throws signals
if set to check depth as 1, stacks of cards will become one object, no bugs!
check depth 2 allows dragging cards out of packs, is buggy still
"""
takes an input ODS file
runs through each sheet taking the top row as the keys and building json data of the other rows
the result json is a list of all rows on all sheets in json format, saved as a file with the orginal filename appended .json
https://pypi.org/project/pyexcel-ods3/
"""
"MultiMeshLineDrawer" object by Richard Ellicott 30/05/2022 (license: public domain or MIT)
script includes auto-setup function that will set up it's own multimesh
This object can draw multiple lines from a stretching and arranging multimesh instances
"""
"MultiMeshLineDrawer" object by Richard Ellicott 30/05/2022 (license: public domain or MIT)
script includes auto-setup function that will set up it's own multimesh
This object can draw multiple lines from a stretching and arranging multimesh instances
func calc_final_transform(_mag_vector,_offset,_width):
"""
this calculates a final transform to rotate a cylinder
this cylinder goes from (0,0,0) to (1,0,0)
so it is basicly 1 unit long along the x axis
"""
Grid Based Pathfinder similar to Dijkstra
Steps:
-searches outwards from the start to find a match to conditions
-follows back from the target to produce coordinates
-trims the results backwards removing coordinates in line with each other
by Richard Ellicott
I provide this code CC0 (completely free):
https://creativecommons.org/share-your-work/public-domain/cc0/