Raised This Month: $ Target: $400
 0% 

Damn Vectors !


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 04-17-2006 , 16:29   Damn Vectors !
Reply With Quote #1

Hey folks.

Given two Vectors, if they are in too close a proximity, I want to move one of them away from the other one.
I can already check if they are too close, it’s the trig side of finding out how to move them directly away from one another that I can't get my head around.

Vector vecDir = pInflictor->WorldSpaceCenter() - pVictim->WorldSpaceCenter();

Looks like a likely candidate but I'm unsure.

If anyone could think of anything off hand I'd appreciate it.

Thanks in advance.

- Jason Croghan
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-18-2006 , 05:25  
Reply With Quote #2

You have two positions (x and y) and want to move one of them (y) away?

Code:
Vector direction = y - x;
direction.Normalize();
y += direction * some_distance_scalar;
Or something like that might work.

The idea is:
1) let direction be y-x. Then direction is the vector you need to add to x in order to get y. So direction is a vector facing directly towards y when its origin is placed on x.
2) Normalize the vector and multiply it by the amount of units you want to move the thing away
3) Add that direction vector to y; thus moving y away from x.
__________________
hello, i am pm
PM is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-26-2006 , 16:07  
Reply With Quote #3

It's not like I'm not calm usually but at the moment I'm getting really FRUSTRATED about this shitty topic. I feel like SCREAMING - I mean, WTF, it's been a week and there's still no answer - either say YES IT WORKED or say NO IT DIDN'T, it did this instead or please at least say "I'll test it later but I HAVE READ YOUR FREAKING REPLY"

Sorry for the caps

__________________
hello, i am pm
PM is offline
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 04-26-2006 , 17:55  
Reply With Quote #4

Bad PM.
__________________
sslice is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 04-27-2006 , 10:49  
Reply With Quote #5

Whoa PM sorry, yeah you were correct. Garry Newman replied to my post on hlcoders about 10 mins before you posted here. I read this, hit Reply and dunno what happened then =P

Cheers for the quick reply, and you were 100% correct, as usual =P
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 04-27-2006 , 11:39  
Reply With Quote #6

PM for President!

Get your PM`08 bumper stickers now, they're going fast and will be sold out before you know it.
L. Duke is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 04-27-2006 , 11:53  
Reply With Quote #7

I'd credit that =)
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 05-10-2006 , 03:38  
Reply With Quote #8

For a seperate function:

So, if i subtract one vector from another, that gives me a location in the center of both (normal)? Regardless of which I subtract from which..

My mind and trig were never meant to be :\

EDIT: LMFAO: nvm, The_WuH helped me out here.
I had thought this was how, but then thought it was too simple for it.

Code:
Vector MidPoint(Vector p1,Vector p2) 
{
   Vector p;

   p.x = (p1.x + p2.x) / 2;
   p.y = (p1.y + p2.y) / 2;
   p.z = (p1.z + p2.z) / 2;

   return p;
}
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode