I made a little function that doesn’t work quite right…

function isPointbetweenTwoOthers (pA, pB, pToCheck) {

`var pApB = new THREE.Vector3(); pApB.subVectors(pA,pB).normalize(); var pBpA = new THREE.Vector3(); pBpA.subVectors(pB,pA).normalize(); var pA_pToCheck = new THREE.Vector3(); pA_pToCheck.subVectors(pA,pToCheck).normalize(); var pB_pToCheck = new THREE.Vector3(); pB_pToCheck.subVectors(pB,pToCheck).normalize(); if(pA_pToCheck.dot(pApB) <0 || pB_pToCheck.dot(pBpA) <0) return false else return true }`

What am I doing wrong? According to the output of my function this left above point is inside the two on the right

**SOLUTION:**

```
function isPointbetweenTwoOthers (pA, pB, pToCheck) {
var nvAtoB = new THREE.Vector3();
nvAtoB.subVectors(pB, pA).normalize();
var nvAtoC = new THREE.Vector3();
nvAtoC.subVectors(pToCheck, pA).normalize();
var nvBtoC = new THREE.Vector3();
nvBtoC.subVectors(pToCheck, pB).normalize();
let epsilon = 0.0016;
let cos90epsi = 1.0 - epsilon;
return nvAtoB.dot(nvAtoC) > cos90epsi && nvAtoB.dot(nvBtoC) < -cos90epsi;
}
```