Skip to content

Instantly share code, notes, and snippets.

View MarcSymonds's full-sized avatar

Marc Symonds MarcSymonds

View GitHub Profile
@MarcSymonds
MarcSymonds / triangle-calculations.js
Last active September 27, 2023 15:00
Javascript code for calculating triangle properties
// Note: Javascript works in radians.
//
// pa, pb, pc are 3 points. Each point is an array with 2 values; x and y
//
function triangleCalculations(pa, pb, pc) {
var a = lineLength(pc, pb); // Length of line from c to b.
var b = lineLength(pa, pc); // Length of line from a to c.
var c = lineLength(pa, pb); // Length of line from a to b.
//var A = Math.acos(((b * b) + (c * c) - (a * a)) / (2 * b * c)); // Angle at point a.
@MarcSymonds
MarcSymonds / ConvertToRomanNumerals.js
Created April 25, 2017 08:42
JavaScript.Example - Convert a number to Roman numerals. Only works effectively up to 9999.
function convertToRoman(num) {
var romanNumerals = [
{number: 1, numeral: "I", sub: 0},
{number: 5, numeral: "V", sub: -1},
{number: 10, numeral: "X", sub: -2},
{number: 50, numeral: "L", sub: -1},
{number: 100, numeral: "C", sub: -2},
{number: 500, numeral: "D", sub: -1},
{number: 1000, numeral: "M", sub: -2}
];
@MarcSymonds
MarcSymonds / MultipleIndexers.cs
Last active June 7, 2019 21:48
C#.Example - Multiple indexers within a class
using System;
using System.Collections.Generic;
/// <summary>
/// Example of multiple indexers within a single class.
///
/// Why you might want/need to do this, who knows?
/// </summary>
namespace CSharp_Examples {
@MarcSymonds
MarcSymonds / MultipleEnumerators.cs
Created April 24, 2017 15:50
C#.Example - Multiple enumerators within a class to enumerate in multiple ways
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// Example of multiple enumerators within a class so that you can enumerate through values
/// hosted by the class in different ways. In this example, one enumerator allows you to go