Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Flip angle horizontally


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-29-2018 , 18:01   [ H3LP ] Flip angle horizontally
Reply With Quote #1

Hello, I'm with a doubt. How I can flip a angle vector horizontally?

I've tried this, but doesn't work as well.

Quote:
The reflected amount (just looking at the maths) would be (180 - angle)

Code:
Angle | Reflection
------+-----------
    0 |        180
   90 |         90
   89 |         91
   91 |         89
  360 |       -180
  270 |        -90
Note the negatives if you fall below the "horizontal plane" - which you could leave as they are, or handle as a special case.
__________________









Last edited by CrazY.; 05-30-2018 at 09:16.
CrazY. is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-30-2018 , 03:34   Re: [ H3LP ] Flip angle horizontally
Reply With Quote #2

Wait, do you have an angle vector (a unit vector pointing into a direction) or a vector of angles in degrees (0-360)?
Even better, show some code.
__________________
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-30-2018 , 09:14   Re: [ H3LP ] Flip angle horizontally
Reply With Quote #3

So, basically what I'm doing is a lasermine. Based in lasermine angle, I will create a velocity vector by the mine aim (velocity_by_aim) and get the end origin in a distance of 9999. After some tests, I see that when I do this while the mine is placed in wall, it work, but if it is in the ground or in "roof" get the inverse direction than I want. Then if it is on the ground, laser will be generated in ground direction, if in roof, laser will be generated in roof direction. I hope you understand, but this was solved.

Code:
new Float:flVecStart[3], Float:flVecEnd[3], Float:flVecPlane[3], Float:flFraction; entity_get_vector(pPlayer, EV_VEC_origin, flVecStart); getAimOrigin(pPlayer, 65, flVecEnd); engfunc(EngFunc_TraceLine, flVecStart, flVecEnd, DONT_IGNORE_MONSTERS, pPlayer, 0); get_tr2(0, TR_flFraction, flFraction); new pHit = max(get_tr2(0, TR_pHit), 0); if (flFraction == 1.0 || pHit) {     zp_colored_print(pPlayer, "You can't set a lasermine at this location.");     return; } get_tr2(0, TR_vecEndPos, flVecEnd); get_tr2(0, TR_vecPlaneNormal, flVecPlane); vectorMulScalar(flVecPlane, 8.0, flVecPlane); // The mine origin vectorAdd(flVecEnd, flVecPlane, g_flVecAim[pPlayer]); // The mine angles vector_to_angle(flVecPlane, g_flVecAngles[pPlayer]); // The mine laser end point vectorMulScalar(flVecPlane, 9999.0, flVecPlane); vectorAdd(g_flVecAim[pPlayer], flVecPlane, g_flVecEnd[pPlayer]);
__________________









Last edited by CrazY.; 05-30-2018 at 09:16.
CrazY. is offline
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 04:32.


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