|
| 20 Apr 2016 01:51 AM |
I am attempting to create a region that is based off of a ray of two positions. The ray can be in all directions and has no limit to length. I wish to create a region around the ray that encompass the area 5 studs away from the ray in all directions.
However I have no idea on how I could get the vector3s for the region from the start and end vectors of the ray. I'm sure there is a solution but how?
In an attempt to understand the idea more I created this model as a frame, https://www.roblox.com/Pos-item?id=401537545 the red part would be the ray, while the black parts represent the vectors for the region and ray. Hopefully it makes sense(named the parts to what they represent)
Thank you in advance, if I need to specify more please tell me.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Apr 2016 09:46 PM |
| I'm pretty sure Region3's can't have a rotation. |
|
|
| Report Abuse |
|
|
|
| 21 Apr 2016 04:20 PM |
Oh yeah, forgot about that.
How else could I do something like this? In my end product I want to get all players inside of a 5 stud radius or so from a ray.
|
|
|
| Report Abuse |
|
|
|
| 21 Apr 2016 04:28 PM |
To figure out if a point P is within 5 studs of a ray:
Find the line which the ray lies on. Find the closest point on the line from the point P. If that closest point is within 5 studs of P, then the condition is met. Otherwise, if the point P is within 5 studs of the endpoints of the ray, the condition is also met.
http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html |
|
|
| Report Abuse |
|
|
|
| 21 Apr 2016 04:29 PM |
| Oh wait the closest point to P also needs to be on the line segment that is the ray. |
|
|
| Report Abuse |
|
|
|
| 21 Apr 2016 05:17 PM |
How would you find the closest point on the line to P though?
Right now the only thing that comes to mind would be to find equation of the line, then find the perpendicular line from the player and the ray, then see if thats 5 studs or larger, so could try and see if I could do that.
Unless theres an easier way to do that?
|
|
|
| Report Abuse |
|
|