Data Realms Fan Forums http://45.55.195.193/ |
|
Velocity Vector Problem http://45.55.195.193/viewtopic.php?f=73&t=18927 |
Page 1 of 1 |
Author: | zalo [ Sun Jun 06, 2010 5:42 pm ] |
Post subject: | Velocity Vector Problem |
I'm visualizing in my head how to make a stable rope for CC (no bouncing or anything). I want to take a portion of a vector and extract it into two separate vectors. Like say take only the velocity of an object that is moving away from another object and separate its total velocity. Then maybe add the velocity that was taken away to the other object. It sounds weird so I drew a picture. ![]() The Grey arrows are the velocity before the script is applied (where the object wants to go). The red ones are what I'd ideally want to happen after the script is applied (the magnitudes aren't quite right). Don't worry, if the object every gets too far away, I can always use set magnitude and the vector away from the object it's in to keep its position in check. I just don't know which of the functions ( http://wiki.datarealms.com/wiki/index.p ... ocs/Vector ) I could use or if it's even possible. Thanks. EDIT: Turns out what I was looking for was called "Vector Projection" and it took until a Calculus 3 class to learn it! They need to teach this kind of stuff in middle school, methinks. |
Author: | Grif [ Sun Jun 06, 2010 5:52 pm ] |
Post subject: | Re: Velocity Vector Problem |
Now, as I understand, what you're saying is, here's object A and object B. Object B is moving away from object B, and when it reaches the end of the rope attaching it to object A, it should both pull on object A, and start traveling around the edge of the circle it's attached to. Yeah? I'm not honestly sure how you'd go about doing that. The circular path is centripetal force, basically, which isn't all that hard to get. You could do a physics problem modeling the impulse force added to object B based on its change in velocity, but... Yeah, that's a pretty good one. |
Author: | CaveCricket48 [ Sun Jun 06, 2010 6:01 pm ] |
Post subject: | Re: Velocity Vector Problem |
Oh, I've done this before. You pretty much want a simulated rope, right? Code: -- Arguments -- -- (Vector) - Anchor Position -- (Vector) - Object Position -- (Vector) - Object Velocity -- Return Value -- -- The altered velocity function RopeVector(ap,op,ov) local curvector = SceneMan:ShortestDistance(op,ap,SceneMan.SceneWrapsX) local pullamountnumber = curvector.AbsRadAngle-ov.AbsRadAngle; if pullamountnumber < 0 then local pullamountnumber = pullamountnumber * -1; end local pullamountnumber = pullamountnumber/(math.pi*2); return ov + (curvector):SetMagnitude(ov.Magnitude*pullamountnumber); end Just stick that in you script and use it as a function. It's completely velocity based, so you'll have to do some postion stuff to orient it to be pixel perfect, I could get that if you want. Whoops, had a little problem. Fixed. |
Author: | zalo [ Sun Jun 06, 2010 6:52 pm ] |
Post subject: | Re: Velocity Vector Problem |
I'll give it a shot, but I'm not sure this is exactly the method I'm looking for. EDIT:Holy moly, remind me to check out your mods more often. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |