*On 11/02/2018 at 07:10, ***xxxxxxxx** wrote:

Ok, made it work.

Had to make sure that the angle remained in the range 0 to PI*2 in some occasions and converted to the range -PI to +PI in others, like this:

```
pi=3.1415926
pi2*2.0*pi
def mod_angle(a) :
if a<0: return (pi2+a)%pi2
return a%pi2
def mod_angle2(a) :
a=mod_angle(a)
if a>pi: return -pi2+a
return a
# ********************************************
camm=cam.GetMg()
campos=cam.GetAbsPos()
camrot=cam.GetAbsRot()
camrot.x=mod_angle(camrot.x)
camrot.y=mod_angle(camrot.y)
camrot.z=mod_angle(camrot.z)
fov=(cam[c4d.CAMERAOBJECT_FOV]+(2*tag[SBC_EXTRA]))/2.0
render=doc.GetFirstRenderData()
xres=render[c4d.RDATA_XRES_VIRTUAL]
yres=render[c4d.RDATA_YRES_VIRTUAL]
yfov=fov*((1.0/xres)*yres)
pol_obj_mt=pol_obj.GetMg()
for i,pp in enumerate(points) :
pt_pos=pp*pol_obj_mt
angle=utils.VectorToHPB(pt_pos-campos)
angle.x=mod_angle(angle.x)
angle.y=mod_angle(angle.y)
angle.z=mod_angle(angle.z)
dangle=angle-camrot
dangle.x=mod_angle2(dangle.x)
dangle.y=mod_angle2(dangle.y)
dangle.z=mod_angle2(dangle.z)
locpos=pt_pos*~camm
if (locpos.z<=0 or dangle.x>=fov or dangle.x<=-fov or dangle.y>=yfov or dangle.y<=-yfov) :
continue
if(locpos.z>0 and (dangle.x<=fov and dangle.x>=-fov and dangle.y<=yfov and dangle.y>=-yfov)) :
# the point in within the camera cone
```

The problem now is that this seems to fail for vertical camera angles that are pointing downwards.

Can someone that is much more knowledgeable than me, check out if I'm doing something wrong.

I just need to make sure a point is within the camera cone, no matter how the camera is oriented.