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 |
|
|
|
| 23 May 2012 04:48 PM |
| Hmm. Literally - infinite - impossible to map out. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 361 |
|
|
| 23 May 2012 05:12 PM |
| Very possible. Every Vector3 by 1s, just 1s. |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 23 May 2012 05:32 PM |
@epicfail22
missed that ^.^ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 23 May 2012 05:35 PM |
Ah darn I forgot to put rotation back in.
nevermind. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 23 May 2012 06:00 PM |
| Um... Wouldn't using a <= or >= operator work? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 23 May 2012 06:08 PM |
| This is much more complicated than it sounds since its rotation matrix could be anything. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
|
| 23 May 2012 08:39 PM |
| @iDigi; Of course it is by ones. I misunderstood you. |
|
|
| Report Abuse |
|
|