generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Vector3 Finding Algorithm

Previous Thread :: Next Thread 
iDigi is not online. iDigi
Joined: 28 Jul 2011
Total Posts: 361
23 May 2012 04:44 PM
I am looking for how I would find all the points in a brick.


Lets say I have a brick at (1, 0, 1); It's size is (5, 5, 5)..

I want to find all Vector3 positions that are inside the brick. I am essentially mapping the brick and recording it on a table, what would this algorithm be, or how would I go about finding it?
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 May 2012 04:48 PM
Hmm. Literally - infinite - impossible to map out.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
23 May 2012 04:52 PM
^Nop


I'm just guessing here but I think it would be if the vector axis are greater than the part's position and less then the part position + the part size
So maybe like

function isInArea(part, pos)
return pos>=part.Position and pos<=part.Position+part.Size
end

but with the axis instead of the actual vector
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 May 2012 05:01 PM
"I want to find all Vector3 positions that are inside the brick"

Like I said, not possible.
Report Abuse
iDigi is not online. iDigi
Joined: 28 Jul 2011
Total Posts: 361
23 May 2012 05:12 PM
Very possible. Every Vector3 by 1s, just 1s.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
23 May 2012 05:32 PM
@epicfail22

missed that ^.^
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
23 May 2012 05:34 PM
function FindBrickCapacity(brick)
local c = CFrame.new(brick.CFrame.p)
local s = brick.Size
return Region3.new(Vector3.new(c.X-s.X/2,c.Y-s.Y/2,c.Z-s.Z/2),Vector3.new(c.X+s.X/2,c.Y+s.Y/2,c.Z+s.Z/2))
end

It returns a Region3 that covers the volume. (Not reliable: I just typed this up now)
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
23 May 2012 05:35 PM
Ah darn I forgot to put rotation back in.




nevermind.
Report Abuse
damanofrunescape is not online. damanofrunescape
Joined: 29 Jul 2008
Total Posts: 7338
23 May 2012 05:47 PM
If you wanted to find EVERY position that fills the square, it'd be impossible.

If you wanted each position every 1 stud it'd be a bit different (not going to spend time trying to figure out rotation, sorry :C)
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
23 May 2012 06:00 PM
Um... Wouldn't using a <= or >= operator work?
Report Abuse
MrMcAero is not online. MrMcAero
Joined: 21 Apr 2012
Total Posts: 671
23 May 2012 06:05 PM
Well,

If your trying to prevent another brick to merge into another brick, the best way to do it would to use some kind of magnitude equation and size equation to figure out the location of the merged part. Or use IsInRegion3 to find if a part is inside the given region. (I think that's the method)

MrMcAero
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
23 May 2012 06:08 PM
This is much more complicated than it sounds since its rotation matrix could be anything.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
23 May 2012 06:14 PM
>Every Vector3 by 1s, just 1s.

Then explain how you are able to put a brick at (0.5, 0.5, 0.5).
Report Abuse
Quenty is online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
23 May 2012 06:16 PM
Not so. Just take out the rotation matric using CFrame. :D

I think....

local Part, Vector3 -- Our variables...

local VectorRelativeToPart = (Part.CFrame - Part.Position):inverse() - Vector3).p

That should give you the Vector3 relative to the part....

Actually... this is better.


local VectorRelativeToPart = (Part.CFrame):inverse() - Vector3).p

Then, all you do is see if...

VectorRelativeToPart.X < Part.Size.X/2 or VectorRelativeToPart.X > -Part.Size.X/2

I think that CFrame math works.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
23 May 2012 06:18 PM
^
Look at this wizard go
Report Abuse
Quenty is online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
23 May 2012 06:19 PM
Late toast.

I was replying to Crazyman32's post.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 May 2012 08:39 PM
@iDigi; Of course it is by ones. I misunderstood you.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image