target = transform.rotation; targetWorldPos = target.toWorld(target.anchorPoint); sample = thisComp.layer("Waves"); offset = -10; for (i = 0; i < height; i++){ if (sample.sampleImage([clamp(targetWorldPos[0]+offset,0,thisComp.width), i], [0.5, 0.5], true)[3] > 0){ top = [0,i]; break; } else { top = [0,thisComp.height]; } } newWorldPos = target.fromWorld(target.toWorld(top)); offsetPos = [target.position[0]+offset,newWorldPos[1]]; for (i = 0; i < height; i++){ if (sample.sampleImage([clamp(targetWorldPos[0],0,thisComp.width), i], [0.5, 0.5], true)[3] > 0){ top = [0,i]; break; } else { top = [0,thisComp.height]; } } targetWorldPos = target.fromWorld(target.toWorld(top)); boatPos = [target.position[0],targetWorldPos[1]]; radians = Math.atan2(boatPos[1] - offsetPos[1],boatPos[0] - offsetPos[0]); radiansToDegrees(radians);