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: Some vector math...

Previous Thread :: Next Thread 
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 07:51 AM
How would I get a 'bounced vector' of a vector?
Like

|
|<--
|
(1,0)
Turns into
|
|-->
|
(-1,0)
And
|
|\
|..\
(0.5,0.5)
Turns into
|../
|/
|
(-.5,.5)

Any formulas?
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 07:54 AM
?

Uhm....

Lol is it just me... but...

{1,0) * {-1, 0}

?
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 07:57 AM
If you multiply vector with -1 you get the opposite direction vector
It would work for something like
|<--

But not for

|\
|..\
Report Abuse
DigitalMirage is not online. DigitalMirage
Joined: 08 Dec 2011
Total Posts: 421
29 Apr 2012 08:02 AM
[ Content Deleted ]
Report Abuse
DigitalMirage is not online. DigitalMirage
Joined: 08 Dec 2011
Total Posts: 421
29 Apr 2012 08:03 AM
[ Content Deleted ]
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 08:04 AM
That's not what I need
Report Abuse
DigitalMirage is not online. DigitalMirage
Joined: 08 Dec 2011
Total Posts: 421
29 Apr 2012 08:05 AM
[ Content Deleted ]
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:05 AM
DigitalMirage, last time i checked abs it gives positive values..?

@su

Our parts (i guess it are parts right? Or if a gui, its 2d) want to have opposite directions.

Well, we can just do

function hit(part)
part.Velocity = part.Velocity * Vector3.new(-1,-1,-1)
end

--well i guess you understand we need an touched event here xD

Lol, its kinda interesting. If you like use -.99 it even slows down a little :D
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
29 Apr 2012 08:07 AM


{x, y} * {-1, -1}
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 08:08 AM
First off.. That's based on roblox physics system thingy..
Second.. That would always go back in the exact direction backwards..
A BOUNCE
Like in 2d sketch

..\
...\< thats the direction
....\
______________
..^le base^

Then it bounces like

....../
...../< le direction
..../
______________
..^le base^

And I'm not talking about objects.. directions AKA vectors
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 08:09 AM
@pwnedu46

That's the same direction backwards.. Not bounce :/
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:13 AM
Hmm wait thats true...

Okay here it comes. - Im not sure if this all mathematically correct.

Bouncing means actually the following.

It bounces, with same speed, to the OPPOSITE angle of it.

If a ball hits a wall with 45 degrees, then it "debounces" with 135 degrees right?

Okay so, if i get this right we need da following.

You need the angle that the part hits the base. I dont really know how to get that.

To get the debouncing angle, you do the following:

angle = 180 - x

You actually need an angle calculator in every brick I think...
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 08:15 AM
But I need also include the angle of the base that the object hits..
?
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:18 AM
Hmm true.

Okay the angle of our ball (the one that hits) is x
The angle of the base is y.

hitangle = math.abs(y-x) --always positive, returns angle that hits. Example: base has angle 90 degrees, x has angle 45 degrees, the hit angle is 45 degrees.

Well, our bounce angle is then..
bounce = 180 - hitangle

Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 08:23 AM
Uhm.. So..

a = object.Direction
b = baseangle
x = math.atan( a.y/a.x )
hitangle = math.abs(b-a)
bounce = 180-hitangle
a = {math.cos(bounce),math.sin(bounce)}

?
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
29 Apr 2012 08:28 AM
Is it like that?
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
29 Apr 2012 08:40 AM
Yes, I think so: You should try it :D
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