Raised This Month: $106 Target: $400
 26% 

[INC] Vector helpers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xXDeathreusXx
Veteran Member
Join Date: Mar 2013
Location: *pPlayer->GetOrigin()
Old 05-29-2018 , 20:03   [INC] Vector helpers
Reply With Quote #1

Extends functionality of SourceMod vectors so you don't have to iterate through array blocks every time you want to do a simple operation on a vector. More or less self explanatory what each of them do, but there is some documentation in there

Included:
  • VectorCopy
  • VectorLerp
  • VectorMulAdd
  • VectorMin
  • VectorMax
  • VectorRand
  • VectorRotate

Some helper functions
  • AnglesNormalize - ensures an angle is within Valves tolerance
  • AngleNormalize - same, but for a single value
  • SinCos - fills in 2 floats with the sin and cosine of the provided radian
  • AngleMatrix - Given an angle, creates a rotation matrix; to be used with VectorRotate
Attached Files
File Type: inc vector_helpers.inc (5.2 KB, 94 views)
__________________
Plugins|Steam Group|Profile
I can do coding and even take requests, but I don't do a bit of modeling

I'm a smartass by nature, get used to it

Last edited by xXDeathreusXx; 08-24-2018 at 20:09. Reason: New file
xXDeathreusXx is offline
Send a message via Skype™ to xXDeathreusXx
xXDeathreusXx
Veteran Member
Join Date: Mar 2013
Location: *pPlayer->GetOrigin()
Old 08-24-2018 , 20:08   Re: [INC] Vector helpers
Reply With Quote #2

New file uploaded, added:
VectorsEqual
VectorIsZero
VectorRotateOnAxis
VectorMatrix
MatrixVectors
MatrixAngles
__________________
Plugins|Steam Group|Profile
I can do coding and even take requests, but I don't do a bit of modeling

I'm a smartass by nature, get used to it

Last edited by xXDeathreusXx; 08-24-2018 at 20:09.
xXDeathreusXx is offline
Send a message via Skype™ to xXDeathreusXx
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Location: Not your business.
Old 08-25-2018 , 13:11   Re: [INC] Vector helpers
Reply With Quote #3

Saves me lots of time, thanks.
__________________
Taking requests, add me on Steam.

People make themselves understood in a way, others understand in another.
mug1wara is offline
Grzyboo
Junior Member
Join Date: Apr 2011
Old 04-14-2019 , 08:02   Re: [INC] Vector helpers
Reply With Quote #4

Code:
stock void VectorRotate(float vec[3], const float matrix[3][3])
{
	vec[0] = GetVectorDotProduct(vec, matrix[0]);
	vec[1] = GetVectorDotProduct(vec, matrix[1]);
	vec[2] = GetVectorDotProduct(vec, matrix[2]);
}
This is fundamentally wrong. You are using already rotated vector values when rotating in next axes.
The rotation matrix values don't seem to be correct either.

Basically, you shouldn't use this .inc file, unless you want to face bugs that are really hard to debug.

Last edited by Grzyboo; 04-14-2019 at 08:07.
Grzyboo is offline
xXDeathreusXx
Veteran Member
Join Date: Mar 2013
Location: *pPlayer->GetOrigin()
Old 04-15-2019 , 03:36   Re: [INC] Vector helpers
Reply With Quote #5

Just copy pasted what was in mathlib, only thing I wrote myself which could be completely wrong is VectorRotateOnAxis
__________________
Plugins|Steam Group|Profile
I can do coding and even take requests, but I don't do a bit of modeling

I'm a smartass by nature, get used to it
xXDeathreusXx is offline
Send a message via Skype™ to xXDeathreusXx
Reply


Thread Tools
Display Modes

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 18:01.


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