<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Rectangle (geoml.Geoml.Rectangle)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.1.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> â€“ <a href="../../index.html">geoml</a> &#x00BB; <a href="../index.html">Geoml</a> &#x00BB; Rectangle</nav><header class="odoc-preamble"><h1>Module <code><span>Geoml.Rectangle</span></code></h1><p>This module provides the basic operations over rectangles</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type" id="type-t" class="anchored"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> = <span class="keyword">private</span> <a href="../Point/index.html#type-t">Point.t</a> * float * float</span></code></div><div class="spec-doc"><p>rectangle type</p></div></div><div class="odoc-spec"><div class="spec value" id="val-make" class="anchored"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span><a href="../Point/index.html#type-t">Point.t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>make p w h, returns a rectangle where p is the bottom-left corner of the rectangle, w its width and h its height</p></div></div><div class="odoc-spec"><div class="spec value" id="val-of_diagonal" class="anchored"><a href="#val-of_diagonal" class="anchor"></a><code><span><span class="keyword">val</span> of_diagonal : <span><a href="../Point/index.html#type-t">Point.t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="../Point/index.html#type-t">Point.t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>of_diagonal p1 p2, builds the rectangle where p1p2 is its diagonal (the bounding rectangle of the two points)</p></div></div><div class="odoc-spec"><div class="spec value" id="val-scale_x" class="anchored"><a href="#val-scale_x" class="anchor"></a><code><span><span class="keyword">val</span> scale_x : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-scale_y" class="anchored"><a href="#val-scale_y" class="anchor"></a><code><span><span class="keyword">val</span> scale_y : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-scale" class="anchored"><a href="#val-scale" class="anchor"></a><code><span><span class="keyword">val</span> scale : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>scale on both axis</p></div></div><div class="odoc-spec"><div class="spec value" id="val-bottom_left" class="anchored"><a href="#val-bottom_left" class="anchor"></a><code><span><span class="keyword">val</span> bottom_left : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../Point/index.html#type-t">Point.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-bottom_right" class="anchored"><a href="#val-bottom_right" class="anchor"></a><code><span><span class="keyword">val</span> bottom_right : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../Point/index.html#type-t">Point.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-top_right" class="anchored"><a href="#val-top_right" class="anchor"></a><code><span><span class="keyword">val</span> top_right : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../Point/index.html#type-t">Point.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-top_left" class="anchored"><a href="#val-top_left" class="anchor"></a><code><span><span class="keyword">val</span> top_left : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../Point/index.html#type-t">Point.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-translate" class="anchored"><a href="#val-translate" class="anchor"></a><code><span><span class="keyword">val</span> translate : <span>float <span class="arrow">&#45;&gt;</span></span> <span>float <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-reflection" class="anchored"><a href="#val-reflection" class="anchor"></a><code><span><span class="keyword">val</span> reflection : <span><a href="../Point/index.html#type-t">Point.t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-contains" class="anchored"><a href="#val-contains" class="anchor"></a><code><span><span class="keyword">val</span> contains : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="../Point/index.html#type-t">Point.t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-area" class="anchored"><a href="#val-area" class="anchor"></a><code><span><span class="keyword">val</span> area : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> float</span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-perimeter" class="anchored"><a href="#val-perimeter" class="anchor"></a><code><span><span class="keyword">val</span> perimeter : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> float</span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-proj_x" class="anchored"><a href="#val-proj_x" class="anchor"></a><code><span><span class="keyword">val</span> proj_x : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> float * float</span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-proj_y" class="anchored"><a href="#val-proj_y" class="anchor"></a><code><span><span class="keyword">val</span> proj_y : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> float * float</span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-intersects" class="anchored"><a href="#val-intersects" class="anchor"></a><code><span><span class="keyword">val</span> intersects : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>determines whether or not two rectangles intersect</p></div></div><div class="odoc-spec"><div class="spec value" id="val-intersect_line" class="anchored"><a href="#val-intersect_line" class="anchor"></a><code><span><span class="keyword">val</span> intersect_line : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="../Line/index.html#type-t">Line.t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="../Point/index.html#type-t">Point.t</a> list</span></span></code></div><div class="spec-doc"><p>returns the intersection points of a rectangle and a line. returns  if they don't intersect.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-segments" class="anchored"><a href="#val-segments" class="anchor"></a><code><span><span class="keyword">val</span> segments : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="../Segment/index.html#type-t">Segment.t</a> list</span></span></code></div><div class="spec-doc"><p>returns a list of length 4 containing the segments of the rectangle</p></div></div><div class="odoc-spec"><div class="spec value" id="val-is_square" class="anchored"><a href="#val-is_square" class="anchor"></a><code><span><span class="keyword">val</span> is_square : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>tests if the sides of the rectangle have same length</p></div></div><div class="odoc-spec"><div class="spec value" id="val-encompass" class="anchored"><a href="#val-encompass" class="anchor"></a><code><span><span class="keyword">val</span> encompass : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="../Point/index.html#type-t">Point.t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>given a rectangle and point, returns the smallest rectangle that contains the point and the rectangle given as parameters</p></div></div><div class="odoc-spec"><div class="spec value" id="val-bounding" class="anchored"><a href="#val-bounding" class="anchor"></a><code><span><span class="keyword">val</span> bounding : <span><span><a href="../Point/index.html#type-t">Point.t</a> list</span> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>given a list of point, returns the smallest rectangle that contains all the points of the list</p></div></div><div class="odoc-spec"><div class="spec value" id="val-centroid" class="anchored"><a href="#val-centroid" class="anchor"></a><code><span><span class="keyword">val</span> centroid : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../Point/index.html#type-t">Point.t</a></span></code></div><div class="spec-doc"><p>returns the gravity center of a rectangle</p></div></div><div class="odoc-spec"><div class="spec value" id="val-random_point" class="anchored"><a href="#val-random_point" class="anchor"></a><code><span><span class="keyword">val</span> random_point : <span><span class="xref-unresolved">Stdlib</span>.Random.State.t <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="../Point/index.html#type-t">Point.t</a></span></code></div><div class="spec-doc"><p>returns a randomly and uniformly chosen point of the rectangle</p></div></div><div class="odoc-spec"><div class="spec value" id="val-print" class="anchored"><a href="#val-print" class="anchor"></a><code><span><span class="keyword">val</span> print : <span><span class="xref-unresolved">Stdlib</span>.Format.formatter <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>printer</p></div></div></div></body></html>