https://wiki.multitheftauto.com/wiki/Math.polygonArea?feed=atom&action=history
Math.polygonArea - Revision history
2024-03-28T10:16:02Z
Revision history for this page on the wiki
MediaWiki 1.39.3
https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&diff=55112&oldid=prev
CrosRoad95: typo
2018-05-25T11:34:32Z
<p>typo</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:34, 25 May 2018</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class="diff-marker"></td><td style="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;"><div>{{Useful Function}}</div></td><td class="diff-marker"></td><td style="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;"><div>{{Useful Function}}</div></td></tr>
<tr><td class="diff-marker"></td><td style="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;"><div>__NOTOC__</div></td><td class="diff-marker"></td><td style="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;"><div>__NOTOC__</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="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;"><div>This function compute area of <del style="font-weight: bold; text-decoration: none;">ony </del>polygon.</div></td><td class="diff-marker" data-marker="+"></td><td style="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;"><div>This function compute area of <ins style="font-weight: bold; text-decoration: none;">any </ins>polygon.</div></td></tr>
<tr><td class="diff-marker"></td><td style="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;"><br/></td><td class="diff-marker"></td><td style="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;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="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;"><div>==Syntax==</div></td><td class="diff-marker"></td><td style="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;"><div>==Syntax==</div></td></tr>
</table>
CrosRoad95
https://wiki.multitheftauto.com/index.php?title=Math.polygonArea&diff=55111&oldid=prev
CrosRoad95: Created page with "{{Useful Function}} __NOTOC__ This function compute area of ony polygon. ==Syntax== <syntaxhighlight lang="lua">float math.polygonArea(float vertex1x, float vertex1y, float v..."
2018-05-25T11:33:29Z
<p>Created page with "{{Useful Function}} __NOTOC__ This function compute area of ony polygon. ==Syntax== <syntaxhighlight lang="lua">float math.polygonArea(float vertex1x, float vertex1y, float v..."</p>
<p><b>New page</b></p><div>{{Useful Function}}<br />
__NOTOC__<br />
This function compute area of ony polygon.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">float math.polygonArea(float vertex1x, float vertex1y, float vertex2x, float vertex2y, float vertex3x, float vertex3y, [...] )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''vertex1x, vertex1y''': First vertex, position `x` and `y`<br />
* '''vertex2x, vertex2y''': Second vertex, position `x` and `y`<br />
* '''vertex3x, vertex3y''': Third vertex, position `x` and `y`<br />
===Optional Arguments===<br />
* '''vertexNx, vertexNy''': Another vertex, any numbers of vertices.<br />
{{OptionalArg}}<br />
===Returns===<br />
Return polygon area in meters^2<br />
<br />
==Code==<br />
<section name="Server- and/or clientside Script" class="both" show="true"><br />
<syntaxhighlight lang="lua"><br />
function math.polygonArea( ...)<br />
local vertices = {...}<br />
local points= {}<br />
<br />
for i=1, #vertices-1, 2 do<br />
points[#points+1] = { x=vertices[i], y=vertices[i+1] }<br />
end<br />
local count = #points<br />
<br />
local area = 0<br />
local j = count<br />
<br />
for i=1, count do<br />
area = area + (points[j].x + points[i].x) * (points[j].y - points[i].y)<br />
j = i<br />
end<br />
<br />
return math.abs(area/2)<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Example usage" class="shared" show="true"><br />
This example compute area of cube 1x1 and triangle, base=5, height=4<br />
<syntaxhighlight lang="lua" lang="lua"><br />
local cubeArea = math.polygonArea(0,0, 1,0, 1,1, 0,1) -- cube -- 1<br />
local triangleArea = math.polygonArea(0,0, 5,4, 5,0) -- triangle -- 10<br />
-- triangleArea<br />
--[[<br />
height: 4<br />
base: 5<br />
area = 1/2 * height * base = 10<br />
area = 1/2 * 4 = 2 * 5 = 10<br />
]]--<br />
print( cubeArea, triangleArea )<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: CrosRoad95, based on https://www.mathopenref.com/coordpolygonarea2.html<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>
CrosRoad95