That worked! Thank you so much!
I just hate it when I run into these speed bumps, which quite frankly is caused by my own lack of attention.
Best regards, Pimms.
 Home
 » Viewing Profile: Posts: Admiral Pimms
Admiral Pimms
Member Since 29 Apr 2011Offline Last Active Dec 11 2012 03:44 PM
Community Stats
 Group Members
 Active Posts 7
 Profile Views 982
 Submitted Links 0
 Member Title Member
 Age Age Unknown
 Birthday Birthday Unknown

Gender
Not Telling
Posts I've Made
In Topic: Individual vertex coloring is somehow disabled.
09 September 2012  01:18 PM
In Topic: Vector transformation
09 August 2011  02:48 AM
Thanks again for your replies 
As it turned out, a Normalized vector is in fact what I was looking for to begin with. Thank you for putting up with my ridiculously bad math knowledge.
//Pimms
As it turned out, a Normalized vector is in fact what I was looking for to begin with. Thank you for putting up with my ridiculously bad math knowledge.
//Pimms
In Topic: Vector transformation
08 August 2011  06:47 PM
I came up with something that works somewhat decent, thought I'd share it as it might be of help to someone out there It's messy as shit, and could use a rewrite, but I'm satisfied considering it's 2:45 AM.
As mentioned, this function returns a vector scaled down to 1.
As mentioned, this function returns a vector scaled down to 1.
inline b2Vec2 scaleVecTo1( b2Vec2 vector ) { //flag for reversing them to negative before return bool invX=NO, invY=NO; float x=0.f, y=0.f; float ratio; invX = vector.x < 0.f ? YES : NO; invY = vector.y < 0.f ? YES : NO; vector.x *= vector.x < 0.f ? 1.f : 1.f; vector.y *= vector.y < 0.f ? 1.f : 1.f; if ( vector.x > vector.y ) { for (;;) { if ( vector.x < 1.0f ) { ratio = 1.f / vector.x; x = vector.x * ratio; y = vector.y * ratio; break; } if ( vector.x > 1.0f ) { ratio = vector.x / vector.x; x = vector.x / ratio; y = vector.y / ratio; break; } } } if ( vector.x <= vector.y ) { for (;;) { if ( vector.y < 1.0f ) { ratio = 1.f / vector.y; y = vector.y * ratio; x = vector.x * ratio; break; } if ( vector.y > 1.0f ) { ratio = vector.y / vector.y; y = vector.y / ratio; x = vector.x / ratio; break; } } } x *= invX ? 1.f : 1.f; y *= invY ? 1.f : 1.f; return b2Vec2(x,y); }
In Topic: Vector transformation
08 August 2011  06:35 PM
Thanks for the quick replies, guys. Appreciate it a lot
@alvaro
I'm not 100% sure of what you mean  what I've tried (without much success) is to first find the ratio between X and Y, based on the highest value.
If the highest value is > 1.0, I divide X and Y by the highest value. This produces some funny results, though.
If the highest value is < 1.0, I find the ratio by dividing 1 by the highest. Then X and Y is divided by ratio.
The current (faulty) code:
@Hassanbasil
I've looked into normalizing the vector, but that would be quite the workaround for me, as I'm calculating the force to be applied as so;
Where hitVector is the vector I'm trying to calculate.
@alvaro
I'm not 100% sure of what you mean  what I've tried (without much success) is to first find the ratio between X and Y, based on the highest value.
If the highest value is > 1.0, I divide X and Y by the highest value. This produces some funny results, though.
If the highest value is < 1.0, I find the ratio by dividing 1 by the highest. Then X and Y is divided by ratio.
The current (faulty) code:
if ( vector.x > vector.y ) { for (;;) { if ( high < 1.0f ) { ratio = 1.f / high; x = high * ratio; y = low * ratio; break; } if ( high > 1.0f ) { ratio = high / high; x = high / ratio; y = low / ratio; break; } } }
@Hassanbasil
I've looked into normalizing the vector, but that would be quite the workaround for me, as I'm calculating the force to be applied as so;
body>ApplyForce( (hitVector*distance)*force, body>GetWorldCenter() );
Where hitVector is the vector I'm trying to calculate.