Results 1 to 4 of 4

Thread: Tutorials Math/Vectors

  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts

    Tutorials Math/Vectors

    Hey,

    does anybody know a good tutorials about the math behind vectors?

    Some people are interested to work on K~Surf, but they lack the math-skills atm.

    Regards


    Collection of Tutorials:

    Bullettrace and you
    http://killtube.org/showthread.php?8...ghlight=vector

    [advanced] movegravity() and movement vectors
    http://killtube.org/showthread.php?8...ghlight=vector
    timescale 0.01

  2. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    You mean something like this:

    A vector in cod is (x,y,z) = (forward, left/right, up). The most used function with vectors in cod are distance, VectorNormalize and VectorToAngles.

    With distance you can calcatulate the distance between two points.

    Example:
    Code:
    one = (0,0,0);
    two = (100, 0, 100);
    dist = Distance( one, two );
    With VectorNormalize you get a vector between 0 and 1. So (0-1, 0-1, 0-1).

    Example:
    Code:
    difference = VectorNormalize( end - start );
    With VectorToAngles you can calculate the angles you need to get from your current position (vector) to a other position.

    Example:
    Code:
    angles = VectorToAngles( end - start );

  3. The Following User Says Thank You to Mitch For This Useful Post:

    kung foo man (18th November 2012)

  4. #3
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Yeah, thats already a good beginning
    timescale 0.01

  5. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Nope, vectornormalize does actually the following:

    Code:
    vec = (123, 234, 345);
    vec = vectornormalize(vec);
    }
    
    vectornormalize(vector)
    {
      l = length(vector);
      vector = maps\mp\_utility::vectorScale(vector, 1/l);
    }
    As you can see, vectornormalize will a vector with exactly the same direction, but with length of one. Always. (although behaviour with vec = (0,0,0) is not defined)

  6. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (18th November 2012)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •