View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:13 am



This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
 Velocity Vector Problem 
Author Message

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Post 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.

Image
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.


Sun Jun 06, 2010 5:42 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Post 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.


Sun Jun 06, 2010 5:52 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Post 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.


Sun Jun 06, 2010 6:01 pm
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Post 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.


Sun Jun 06, 2010 6:52 pm
Profile WWW
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.044s | 13 Queries | GZIP : Off ]