Skip to content

Instantly share code, notes, and snippets.

View peteflorence's full-sized avatar

Pete Florence peteflorence

View GitHub Profile
@wngreene
wngreene / bag_to_images.py
Last active May 2, 2024 05:14
Extract images from a rosbag.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016 Massachusetts Institute of Technology
"""Extract images from a rosbag.
"""
import os
import argparse
@nim65s
nim65s / gist:5e9902cd67f094ce65b0
Created January 5, 2015 12:57
distance from point to line segment…
from numpy import arccos, array, dot, pi
from numpy.linalg import det, norm
def distance(A, B, P):
""" segment line AB, point P, where each one is an array([x, y]) """
if all(A == P) or all(B == P):
return 0
if arccos(dot((P - A) / norm(P - A), (B - A) / norm(B - A))) > pi / 2:
return norm(P - A)
if arccos(dot((P - B) / norm(P - B), (A - B) / norm(A - B))) > pi / 2: