 # How to get the size of a part normal/surface?

is there a way to get the surface size of a part only using a ray normal??

Edit: Oops, I thought it returned the surface of the part that it hit rather than the surface normal.
What do you want this for? If you give more specifics, I will see about a more specific answer. Until then, here is an answer to your original question. The surface normal will be a single number on one of the axes:

``````0,0,1
0,0,-1
0,1,0
...
``````

The size of that surface is the Size property of the two axes that are designated by zeroes.
So if the surface normal is `0, 1, 0`, the surface area will be `size.X*size.Z`

1 Like

This isn’t the case if the instance is rotated, for example, with an object rotated 45 degrees on the z-axis, casting a ray that hits the top surface will have the normal be `√2/2, 0, √2/2` (0.707, 0, 0.707), but this has given me an interesting idea on how to solve it:

We can use `VectorToObjectSpace` on the part’s cframe to get a vector representing the normal relative to the part’s cframe, for example, hitting the top surface of a part will always return `0, 1, 0`. Looking at a few specific cases, hitting the top side (normal: `0, 1, 0` of a part for example, the surface size would be size.x * size.z – one interesting thing about this is that the size uses the axes where the dimensions are 0. With this, we can subtract 1 from each axis of the relative normal to make a new vector and then multiply it by the part’s size to get the surface size. We use `math.abs` here since the top and bottom surfaces would have the same surface size, however the relative normal of the top is surface is `0, 1, 0` and the relative normal of the bottom surface is `0, -1, 0` and 1 - (-1) is 2, so we use math.abs to get the absolute value (one which is always positive) so that for the bottom surface, it will be 1, 0, 1, just the same as the top surface.

Here’s a code sample – given that `result` is the raycast result returned by WorldRoot:Raycast:

``````local part = result.Instance
local rel_normal = part.CFrame:VectorToObjectSpace(result.Normal)
local size = Vector3.new(1 - math.abs(rel_normal.x), 1 - math.abs(rel_normal.y), 1 - math.abs(rel_normal.z)) * part.Size
print(size) -- the surface size
``````
4 Likes