# Simple Vector (Math) Question

**URL:** <https://forum.kirupa.com/t/simple-vector-math-question/278123>\
**Category:** programming\
**Created:** [December 22, 2008, 7:30pm UTC](https://forum.kirupa.com/t/simple-vector-math-question/278123 "2008-12-22T19:30:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![El\_Phantom](https://avatars.discourse-cdn.com/v4/letter/e/d6d6ee/32.png) [@El\_Phantom](https://forum.kirupa.com/u/El_Phantom)\
**Post date:** [December 22, 2008, 7:30pm UTC](https://forum.kirupa.com/t/simple-vector-math-question/278123/1 "2008-12-22T19:30:00Z")

</div>

Hey everyone, simple question for any of you who use Vectors.

I’m trying to figure out how to implement SAT (Separating Axis Theorem) for a collision detection script i’m writing, and I have most of it down, but i’m coming into problems when I calculate the Vectors of my polygons that I am projecting on each edge axis.

Basically my problem is this: given a square (or any other polygon), how do i calculate the vectors to project on each axis?

here are the two methods i’ve tried:  
given a square 3 units in width and height, starting at coordinate 0,0:

![](http://ftp.magicality.com/myspace/sat_example.jpg)

Method 1 seems like it would be the correct method, but it gives me poor results, i have followed some examples online and I think the rest of my math is good, but the negative numbers are throwing things off.

Method 2 however gives me better results, but it won’t get certain intersections, plus it just doesn’t seem right, what with \<0, 0\> being a vector. Is there another method I haven’t tried or is Method 1 or Method 2 correct and my problem lies elsewhere?

please help! (this is driving me crazy)
