Skip to content

Instantly share code, notes, and snippets.

@se5a
se5a / .cs
Last active May 13, 2023 00:09
Using matrix transforms for ellipse arcs.
public static DVec.Vector2[] EllipseFullMtxSweep(double semiMaj, double eccentricity, double tilt, double start,
double sweep, int numPoints)
{
//convert ellipse angles to circle angles.
double b = semiMaj * Math.Sqrt(1 - eccentricity * eccentricity);
start = Math.Atan(semiMaj / b * Math.Tan(start));
sweep = Math.Atan(semiMaj / b * Math.Tan(sweep));
double end = start + sweep;
double Δθ = 2 * Math.PI / (numPoints - 1) * Math.Sign(sweep); //arc increment for a whole circle
@se5a
se5a / gist:1135132f0f2d8d84770ca960405b9e41
Last active April 27, 2023 10:45
Draw ellipse with a fixed number of points.
//taken from: https://doi.org/10.1093/comjnl/14.1.81
public static (int x, int y)[] EllipseArrayFromPaper(double semiMaj, double semiMin, double tilt, int numPoints)
{
(int x, int y)[] points = new (int x, int y)[numPoints];
var n = numPoints;
var a = semiMaj;
var b = semiMin;
var xc = 0; //this is the center position of the ellipse;
var yc = 0;
@se5a
se5a / matrix2d.cs
Created August 4, 2020 23:06
2dMatrixMath
using System;
using System.Collections.Generic;
namespace Pulsar4X.Orbital
{
public class Matrix2d
{
double[] X = new double[3] { 1, 0, 0 };
double[] Y = new double[3] { 0, 1, 0};
double[] Z = new double[3] {0, 0, 1};
unsafe
{
string rf = "Resources";
ImFontConfig* rawPtr = ImGuiNative.ImFontConfig_ImFontConfig();
ImFontConfigPtr config = new ImFontConfigPtr(rawPtr);
config.PixelSnapH = true;
config.MergeMode = true;
ImFontAtlasPtr fontAtlas = ImGui.GetIO().Fonts;
public static bool Switch2State(string label, ref bool state, string leftState = "Off", string rightState = "On")
{
int intState = Convert.ToInt32(state);
string strstate = leftState;
if (state == true)
strstate = rightState;
var txtWid = Math.Max(ImGui.CalcTextSize(leftState).X, ImGui.CalcTextSize(rightState).X);
ImGui.PushItemWidth(txtWid * 3);
var cpos = ImGui.GetCursorPos();
if(ImGui.SliderInt(label,ref intState, 0, 1, "" ))
@se5a
se5a / gist:6cb1383b10cf2b4c4cf9abdffd642337
Last active August 5, 2020 09:52
Dear Imgui GetPos and GetSize demo.
public static class SizesDemo
{
enum FrameOfReference : byte
{
Screen,
Window,
}
static ImDrawListPtr _wdl = ImGui.GetForegroundDrawList();
static Vector2 _windowPos = new Vector2();
static UInt32 _lineColour = ImGui.GetColorU32(new Vector4(1, 0, 0, 1));
@se5a
se5a / gist:aa83958a981942e12121e5a36ea74fba
Created April 29, 2020 02:29
Using BorderGroup and BorderListOptions
private int _bloSelectedIndex = -1;
void BorderListOptionsWiget()
{
string[] items = new string[_listfoo.Count];
for (int i = 0; i < _listfoo.Count; i++)
{
items[i] = _listfoo[i].name;
}
BorderGroup.Begin("Border List Options: ");
BorderListOptions.Begin("blo", items, ref _bloSelectedIndex, 64);
@se5a
se5a / gist:d6783dfdb0fddfc9b50a2db96b52bb34
Created April 29, 2020 02:28
BorderGroup, and BorderListOptions
public static class BorderListOptions
{
private static Vector2 _labelSize = new Vector2();
private static float _xleft;
private static float _xcentr;
private static float _xright;
private static float _ytop;
private static float _yctr1;
@se5a
se5a / gist:ee2c815d295d3210493437fa4e5880b3
Created April 25, 2020 21:20
steam proton log Aurora
======================
Proton: 1586972103 proton-5.0-6
SteamGameId: 14948375713730789376
Command: ['/mnt/98448323-4372-4c8a-904a-30b587cc3685/Games/Aurora/Aurora.exe', '--wine']
Options: {'forcelgadd'}
======================
ERROR: ld.so: object '/home/se5a/.steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/se5a/.steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/se5a/.steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/se5a/.steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
@se5a
se5a / gist:b66b9d3cd86992c4cae38888c97ff9c7
Last active April 21, 2020 21:57
Nested BorderGroup
public class BorderGroup
{
private static Vector2[] _startPos = new Vector2[8];
private static Vector2[] _labelSize = new Vector2[8];
private static uint[] _colour = new uint[8];
private static byte _nestIndex = 0;
private static float _dentMulitpier = 3;
public static void BeginBorder(string label, uint colour)
{
ImGui.PushID(label);