• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

SFX Pitch/Roll/Yaw action not working as intended?

Status
Not open for further replies.
Level 14
Joined
Jan 16, 2009
Messages
716
This should work when x and y are not equal to 0 but it should be fairly easy to implement a solution for those cases. There is probably a more optimized way of doing what I am doing here.
I will do so when I have the time to work on the system again.

JASS:
    struct MissileVector3
        real x
        real y
        real z
   
        //yaw
        //zero safety in case of y==0 or (y==0 and x==0)
        method operator angleX takes nothing returns real
            local real ix = RAbsBJ(this.x)
            local real iy = RAbsBJ(this.y)
            return Atan(this.z/this.y)*(1-(ix/(ix+iy)))
        endmethod

        //pitch
        //zero safety in case of x==0 or (x==0 and y==0)
        method operator angleY takes nothing returns real
            local real ix = RAbsBJ(this.x)
            local real iy = RAbsBJ(this.y)
            return -Atan(this.z/this.x)*(1-(iy/(ix+iy)))//the - is not a mistake
        endmethod
   
        //roll
        method operator angleZ takes nothing returns real
            return Atan2(this.y,this.x)
        endmethod
    endstruct

I still haven't gotten around to finishing the system that this is part of because of all the fringe cases I encountered.
 
Status
Not open for further replies.
Top