```
//pseudocode
bool IsPointLitBySpotlight(Vector3 point, SpotLight spotlight)
{
//if spotlight is valid
//if is enabled
//if intensity is zero the point is not lit
//if the distance is greater than the attenuation radius then it's not lit
if (spotlight == nullptr ||
!spotlight.IsEnabled() ||
spotlight.GetIntensity() == 0 ||
Vector3.Distance(point,spotlight.location) > spotlight.getAttenuationRadius())
return false;
//check if the point is inside the cone
//
//vector pointing from spotlight to point
//remember to check if length is zero (point in the same location of the spotlight) when calculating a normal
Vector3 unitdirectionvector = (point - spotlight.GetLocation()).getNormal();
//the dot product will be 1 when the point is exactly in the forward vector's line of the spotlight
//and will go towards 0 when perpendicular
float dot = Vector3.dotProduct(spotlight.getForwardVector(), unitdirectionvector);
//with acosd we get the angle between the vector pointing from the spotlight to the point
//and the spotlight forward vector (line at the center of the cone)
float angle_point_spotlight = Math.acosd(dot);
//in this example the cone angle is from the forward vector to the outer edge (so it's the half angle)
if (angle_point_spotlight > spotlight.getConeAngle()):
return false;
//now we are inside the spotlight cone but now you should check
//if there aren't objects blocking the spotlight
bool hit = Physics.visibilityLinetrace(point,spotlight)
return !hit;
}
```