<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Vector3:compare?action=history&amp;feed=atom</id>
	<title>Vector3:compare - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Vector3:compare?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Vector3:compare&amp;action=history"/>
	<updated>2026-05-15T09:32:24Z</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=Vector3:compare&amp;diff=49967&amp;oldid=prev</id>
		<title>Myonlake: Added Vector3:compare method to the Useful Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Vector3:compare&amp;diff=49967&amp;oldid=prev"/>
		<updated>2016-12-28T19:42:16Z</updated>

		<summary type="html">&lt;p&gt;Added Vector3:compare method to the Useful Functions&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;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This method checks whether two [[Vector3|vectors]] match (optionally with precision defined).&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool Vector3:compare ( Vector3 comparison [ , float precision ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''comparison:''' The [[Vector3]] to compare to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
* '''precision:''' A [[float]] representing the precision of the comparison.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
A [[boolean]] representing whether the vectors match taking into account the precision.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function Vector3:compare( comparison, precision )&lt;br /&gt;
	assert( type( comparison.getLength ) == 'function', &amp;quot;First argument must be a Vector3.&amp;quot; )&lt;br /&gt;
	assert( not precision or type( precision ) == 'number', &amp;quot;Precision type must be a number, got &amp;quot; .. type( precision ) .. &amp;quot;.&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
	if ( not precision ) then&lt;br /&gt;
		if ( self:getX( ) ~= comparison:getX( ) ) or&lt;br /&gt;
		   ( self:getY( ) ~= comparison:getY( ) ) or&lt;br /&gt;
		   ( self:getZ( ) ~= comparison:getZ( ) ) then&lt;br /&gt;
			return false&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if ( math.abs( self:getX( ) - comparison:getX( ) ) &amp;gt; precision ) or&lt;br /&gt;
		   ( math.abs( self:getY( ) - comparison:getY( ) ) &amp;gt; precision ) or&lt;br /&gt;
		   ( math.abs( self:getZ( ) - comparison:getZ( ) ) &amp;gt; precision ) then&lt;br /&gt;
			return false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Myonlake</name></author>
	</entry>
</feed>