# (geometry)Rotating Calipers / Oriented Minimum Bounding Box?

**URL:** <https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058>\
**Category:** Geo\
**Created:** [July 31, 2020, 8:13pm UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058 "2020-07-31T20:13:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [July 31, 2020, 8:13pm UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058/1 "2020-07-31T20:13:57Z")

</div>

Are there any implementations for, rotating calipers algorithm or any oriented minimum bounding box here in Julia? I could whip one up if not, but preferably one of you wizards has one out there somewhere.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [August 1, 2020, 2:18am UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058/3 "2020-08-01T02:18:18Z")

</div>

I whipped up the naive versions using the following references:

> **[Convex Hull using Jarvis' Algorithm or Wrapping - GeeksforGeeks](https://www.geeksforgeeks.org/convex-hull-using-jarvis-algorithm-or-wrapping/)**
>
> A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

> <https://stackoverflow.com/questions/13542855/algorithm-to-find-the-minimum-area-rectangle-for-given-points-in-order-to-comput>

Code is here: [MBR.jl · GitHub](https://gist.github.com/caseykneale/6038bc92bbc38d7c7a2752e88ab84513)

Kinda slow, some of that’s due to the algorithms(not SOTA’s), but also trying to use GeometryBasics.jl made my code a little clunky. I like some of the primitives but sometimes you just need linear algebra 🤷‍♂️ .

Might be a fun test case for optimization though… Seems to work, but I bet there’s a 1 off error in there somewhere.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [August 1, 2020, 1:11pm UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058/4 "2020-08-01T13:11:00Z")

</div>

here’s a faster version not using GeometryBasics

[https://gist.github.com/caseykneale/496bf2ec486fd24ce959ef15fd2edfde](https://gist.github.com/caseykneale/496bf2ec486fd24ce959ef15fd2edfde)

Doubt anyones following along but figured if someone else finds this thread they might appreciate it.

---

<div class="post-metadata">

**Author:** ![maxfreu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxfreu/32/17468_2.png) [@maxfreu](https://discourse.julialang.org/u/maxfreu)\
**Post date:** [August 25, 2020, 7:53pm UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058/5 "2020-08-25T19:53:08Z")

</div>

Is this related to your experiments [here](https://discourse.julialang.org/t/less-than-approx-equals/45436/3)?

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [August 25, 2020, 8:26pm UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058/6 "2020-08-25T20:26:09Z")

</div>

It’s related in that both of these are small units of code hobby for projects :). But no these two projects don’t coincide. This is a plop of code that is useful for Computer Vision (other things too). The two things could be made to relate though! Line segment intersections and bounding rectangles are used in video games and other areas.

I have 2-3 pet projects to try and get some attention for job hunts, and I have an invited guest lecture at a large university coming up soon so I have to do some tinkering on a few disparate things.

---

<div class="post-metadata">

**Author:** ![maxfreu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxfreu/32/17468_2.png) [@maxfreu](https://discourse.julialang.org/u/maxfreu)\
**Post date:** [August 26, 2020, 10:55am UTC](https://discourse.julialang.org/t/geometry-rotating-calipers-oriented-minimum-bounding-box/44058/7 "2020-08-26T10:55:50Z")

</div>

That sounds good 🙂 It seems like you are fit in this stuff; have you considered Grassmann.jl + [projective geometric algebra](https://www.youtube.com/watch?v=tX4H_ctggYo)? I’m currently trying to wrap my head around it and trying to implement the PGA [cheat sheets](https://bivector.net/doc.html) - but its a dark path all alone 😃 and interfacing between Grassmann and the rest of julia is a bit mysterious (to me).
