What is the isClose method of Vector3s for?


  • I was reading about Vector3s today, and I came across an interesting method called isClose. Now, I did some testing, and the method yielded some really confusing results. I did some research into what an epsilon radius is, and I only found a reference to an epsilon neighborhood and the fact that it is a Greek letter of the alphabet. I found nothing really specific as to what was really going on. Here is my script that I used for testing, along with images of what resulted:

    local partPos = workspace.Part.Position
    local part = Instance.new("Part")
    local num = 5
    
    part.CanCollide = false
    part.Anchored = true
    part.BrickColor = BrickColor.new("Really red")
    
    
    for i = -255, 255, 5 do
    	for j = -255, 255, 5 do
    		local newPart = part:Clone()
    		local newPartPos = Vector3.new(i, 0.5, j)
    		newPart.Position =  newPartPos
    		if newPartPos:isClose(partPos, num) then
    			newPart.BrickColor = BrickColor.new("Bright green")
    		end
    		newPart.Parent = workspace
    	end
    end
    


    When the num variable is 1:

    When the num variable is 15:

    When the num variable is 50:

    Another interesting thing is that, if I change the size of the part/its position, the result changes as well. For all of the above tests, the part size was Vector3.new(4, 14, 2). Does anyone have a clue what is going on? Thank you (I ask that people who don't know what they are talking about would not respond as they have in other threads)!


  • I've also tried observing this method in action in 3D, but it still yields no comprehensible patterns (at least to me). Here is the script so you can mess around with it:

    local basePart = Instance.new("Part")
    local partPos = Vector3.new(0, 100, 0)
    
    basePart.Position = partPos
    basePart.BrickColor = BrickColor.new("Really black")
    basePart.Anchored = true
    basePart.Size = Vector3.new(5, 5, 5)
    basePart.Parent = workspace
    
    local part = Instance.new("Part")
    local num = 15
    
    part.CanCollide = false
    part.Anchored = true
    part.BrickColor = BrickColor.new("Really red")
    
    for i = 1, 200, 5 do
    	for j = -255, 255, 5 do
    		for k = -255, 255, 5 do
    			local newPart = part:Clone()
    			local newPartPos = Vector3.new(j, i, k)
    			newPart.Position =  newPartPos
    			if newPartPos:isClose(partPos, num) then
    				newPart.BrickColor = BrickColor.new("Bright green")
    			end
    			newPart.Parent = workspace
    		end
    		wait(0.05)
    	end
    	wait(1)
    end
    
Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.