15 - Separating Axis Theorem/script.js
//returns the min and max projection values of a shape onto an axis

returns the min and max projection values of a shape onto an axis
returns the min and max projection values of a shape onto an axis
function projShapeOntoAxis(axis, obj){
    let min = Vector.dot(axis, obj.vertex[0]);
    let max = min;
    for(let i=0; i<obj.vertex.length; i++){
        let p = Vector.dot(axis, obj.vertex[i]);
        if(p<min){
            min = p;
        } 
        if(p>max){
            max = p;
        }
    }
    return {
        min: min,
        max: max
    }
}
function projShapeOntoAxis ( axis , obj ) { let min = Vector . dot ( axis , obj . vertex [ 0 ] ) ; let max = min ; for ( let i = 0 ; i < obj . vertex . length ; i ++ ) { let p = Vector . dot ( axis , obj . vertex [ i ] ) ; if ( p < min ) { min = p ; } if ( p > max ) { max = p ; } } return { min : min , max : max } }
returns the min and max projection values of a shape onto an axis
returns the min and max projection values of a shape onto an axis