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 » Scripters
Home Search
 

Re: Ray Reflection (For Ray-tracing and Physics)

Previous Thread :: Next Thread 
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
17 May 2009 02:33 PM
Could someone help me create a function to reflect a ray, after bouncing off of a plane?
(Yes, this IS the correct forum. No one in 'Script Help' would be able to help me. This is very complex)
Assuming a ray with lookVector 'r' hit a plane with a outward-facing lookVector 'p', then what would the resulting lookVector of the resulting ray be? ('h')

If someone could help, I can finish my ray-tracer and physics engine.
Report Abuse
foofoogouls4 is not online. foofoogouls4
Joined: 14 Jul 2008
Total Posts: 532
17 May 2009 02:38 PM
I dont get it . . . and I'm in a tenth grade honors math class, and science
Report Abuse
MrDoomBringer is not online. MrDoomBringer
Top 100 Poster
Joined: 21 Nov 2006
Total Posts: 6176
17 May 2009 03:06 PM
You won't get into this kind of stuff until you're taking a degree in computer science.

That's going to be a lot of heavy math, good luck.
Report Abuse
Connolly is not online. Connolly
Joined: 28 Mar 2008
Total Posts: 5740
17 May 2009 03:07 PM
MrDoomBringer how are you in the top 100 posts when I have more post then you and i'm not?
Report Abuse
Wyoming is not online. Wyoming
Joined: 05 Feb 2008
Total Posts: 8453
17 May 2009 03:46 PM
A lot of early accounts like 06 have the Top 100 Posts thing as a glitch, or maybe just cuz's MDB's a Super Mod. Who knows...XD
Report Abuse
catmaster56 is not online. catmaster56
Joined: 16 Oct 2008
Total Posts: 3647
17 May 2009 03:48 PM
phew then i shouldnt feel bad that i dont know this...
Report Abuse
Meelo is not online. Meelo
Joined: 04 Jul 2008
Total Posts: 14763
17 May 2009 03:51 PM
Yeah. If you could figure out the degree of slope coming into the plane, I might be able to help you...
Report Abuse
DingDong272 is not online. DingDong272
Top 100 Poster
Joined: 08 Dec 2007
Total Posts: 9860
17 May 2009 04:34 PM
Yes, Meelo's right. Finding which way it would bounce off (assuming a laser with a mirror) is easy(ier) once you have found the angle that the lookVector is coming from.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
17 May 2009 04:40 PM
That's nice.
Report Abuse
Meelo is not online. Meelo
Joined: 04 Jul 2008
Total Posts: 14763
17 May 2009 04:52 PM
It's trivial in 2D, and you can probably reduce it to a 2D problem.
Report Abuse
eyeontheprize is not online. eyeontheprize
Joined: 17 Dec 2007
Total Posts: 7270
17 May 2009 05:44 PM
Inverse of the ray's incoming angle
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
17 May 2009 06:13 PM
I think you people need to think more 2D right now rather than 3D and use Z as 0 for everything, like MDB said, it's ub3r h4x from this.

Think about a ray coming at a plane, and the ray is coming at an angle of 45 degrees.

We need a full half circle; 180 degrees. So The two sides of the surface are at 0 and 180. That's two. We have the other angle of 45. That's three angles. Take the ray's angle and subtract it from 180 to make it flip to the other side. This case would be 135 degrees. The lines would be:

0, 45, 135, 180. So use some trigonometry (sine, cosine, tangent) to find a looking direction of the new line.

If we find the difference of the thrird subtracted by the second, we get a number that we need. In this case, it's 135 - 45, or 90.

---

Consider this case in 2D.

- A ray is coming from 0,0 heading to 1,0.
- A surface/mirror is point 3,-1 to 5, 1 (slope of 1, 45 degree, diagonal).
- The ray hits the surface at 4,0.
- If you use the special number from above, which is 90, rotate the direction the ray is heading using trig. functions.
- We find that the new direction has an infanate slope (is this dangerous!?).

---

I can draw this out....like really good. Anyone interested?
Report Abuse
Meelo is not online. Meelo
Joined: 04 Jul 2008
Total Posts: 14763
17 May 2009 07:31 PM
"- We find that the new direction has an infanate slope (is this dangerous!?). "

Which is why you always check to see if an angle is 0 or pi before you use a tangent.
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
17 May 2009 07:55 PM
Yea, separating axis theorem can probably be applied to solve it...
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
17 May 2009 09:26 PM
Well knowing Lua, it handles infinate numbers pretty well.
Report Abuse
MrDoomBringer is not online. MrDoomBringer
Top 100 Poster
Joined: 21 Nov 2006
Total Posts: 6176
17 May 2009 09:49 PM
For the last time: Ignore the top 100 stuff. It's been broken and not working right since before I joined Roblox.

Edit:

Also, Lua does not handle infinite loops or numbers very well.
Report Abuse
MicroUser is not online. MicroUser
Joined: 29 Mar 2009
Total Posts: 3601
17 May 2009 10:02 PM
[ Content Deleted ]
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
18 May 2009 03:37 PM
Micro, it inverses it, not the same direction. Same angle from the other side, but not direction.

I think Lua can handle enough infinity for a line to be reflected.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
18 May 2009 04:51 PM
The problem is, I don't know trigonometry, or this would be easier.

I need an actual equation, or I can't underdtand it. XD
(I get equations better than literal words)
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
18 May 2009 06:17 PM
Lol, even if you did know trigonometry it would be far from easier...

This might be helpfull if you're looking for a solid formula:

local vec1, vec2
local ang = math.acos(vec1.unit.x*vec2.unit.x + vec1.unit.y*vec2.unit.y + vec1.unit.z*vec2.unit.z)

where ang is the smallest angle between the two vectors
Report Abuse
imaminer99 is not online. imaminer99
Joined: 01 Feb 2011
Total Posts: 894
05 Mar 2013 02:56 PM
NO
Report Abuse
DannyCore is not online. DannyCore
Joined: 25 Apr 2012
Total Posts: 990
05 Mar 2013 03:16 PM
what the heck was that "NO" for?
Report Abuse
Garnished is not online. Garnished
Joined: 09 Apr 2012
Total Posts: 12695
05 Mar 2013 03:59 PM
@MrDoomBring
>Degree in computer science
NXTBoy did it.
Report Abuse
Garnished is not online. Garnished
Joined: 09 Apr 2012
Total Posts: 12695
05 Mar 2013 03:59 PM
@MrDoomBringer
>Degree in computer science
NXTBoy did it.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
05 Mar 2013 04:11 PM
i was gonna tell everyone about super maths and then

"2009"

:(
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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