Skip to content

Instantly share code, notes, and snippets.

View JoshData's full-sized avatar

Joshua Tauberer JoshData

View GitHub Profile
@JoshData
JoshData / gist:08cdd028f332c550fce2d3ba40d94396
Created April 9, 2021 18:45
is_point_on_line_segment in C++
// See if pt is between pt0 and pt1.
// via stackoverflow https://stackoverflow.com/a/328122
auto is_between = [](VertexType pt, VertexType p0, VertexType p1) {
auto z = (pt.y - p0.y) * (p1.x - p0.x)
- (pt.x - p0.x) * (p1.y - p0.y);
if (abs(z) > .0001) return false;
auto d = (pt.x - p0.x) * (p1.x - p0.x)
+ (pt.y - p0.y) * (p1.y - p0.y);
if (d < 0) return false;
auto n2 = (p1.x - p0.x) * (p1.x - p0.x)
@JoshData
JoshData / WinFormsTreeViewDragDropWithDottedBoxAroundTarget.cs
Last active June 17, 2022 14:30
System.Windows.Forms TreeView Drag-Drop with Dotted Box Around Drop Target
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WinFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{