<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Math.polygonArea?action=history&amp;feed=atom</id>
	<title>Math.polygonArea - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Math.polygonArea?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&amp;action=history"/>
	<updated>2026-05-15T15:54:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&amp;diff=55112&amp;oldid=prev</id>
		<title>CrosRoad95: typo</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&amp;diff=55112&amp;oldid=prev"/>
		<updated>2018-05-25T11:34:32Z</updated>

		<summary type="html">&lt;p&gt;typo&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:34, 25 May 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Useful Function}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Useful Function}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__NOTOC__&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__NOTOC__&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This function compute area of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ony &lt;/del&gt;polygon.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This function compute area of &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;any &lt;/ins&gt;polygon.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Syntax==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Syntax==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>CrosRoad95</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&amp;diff=55111&amp;oldid=prev</id>
		<title>CrosRoad95: Created page with &quot;{{Useful Function}} __NOTOC__ This function compute area of ony polygon.  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt;float math.polygonArea(float vertex1x, float vertex1y, float v...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&amp;diff=55111&amp;oldid=prev"/>
		<updated>2018-05-25T11:33:29Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function compute area of ony polygon.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;float math.polygonArea(float vertex1x, float vertex1y, float v...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function compute area of ony polygon.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;float math.polygonArea(float vertex1x, float vertex1y, float vertex2x, float vertex2y, float vertex3x, float vertex3y,  [...] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''vertex1x, vertex1y''': First vertex, position `x` and `y`&lt;br /&gt;
* '''vertex2x, vertex2y''': Second vertex, position `x` and `y`&lt;br /&gt;
* '''vertex3x, vertex3y''': Third vertex, position `x` and `y`&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''vertexNx, vertexNy''': Another vertex, any numbers of vertices.&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
===Returns===&lt;br /&gt;
Return polygon area in meters^2&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server- and/or clientside Script&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function math.polygonArea( ...)&lt;br /&gt;
  local vertices = {...}&lt;br /&gt;
  local points= {}&lt;br /&gt;
&lt;br /&gt;
  for i=1, #vertices-1, 2 do&lt;br /&gt;
    points[#points+1] = { x=vertices[i], y=vertices[i+1] }&lt;br /&gt;
  end&lt;br /&gt;
  local count = #points&lt;br /&gt;
&lt;br /&gt;
  local area = 0&lt;br /&gt;
  local j = count&lt;br /&gt;
&lt;br /&gt;
  for i=1, count do&lt;br /&gt;
    area = area +  (points[j].x + points[i].x) * (points[j].y - points[i].y)&lt;br /&gt;
    j = i&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  return math.abs(area/2)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example usage&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example compute area of cube 1x1 and triangle, base=5, height=4&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local cubeArea = math.polygonArea(0,0, 1,0, 1,1, 0,1) -- cube -- 1&lt;br /&gt;
local triangleArea = math.polygonArea(0,0, 5,4, 5,0) -- triangle -- 10&lt;br /&gt;
-- triangleArea&lt;br /&gt;
--[[&lt;br /&gt;
  height: 4&lt;br /&gt;
  base: 5&lt;br /&gt;
  area = 1/2 * height * base = 10&lt;br /&gt;
  area = 1/2 * 4 = 2 * 5 = 10&lt;br /&gt;
]]--&lt;br /&gt;
print( cubeArea, triangleArea )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: CrosRoad95, based on https://www.mathopenref.com/coordpolygonarea2.html&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>CrosRoad95</name></author>
	</entry>
</feed>