Do these functions exist?

I’m having a difficult time finding these functions on the wiki, because I don’t exactly know what they would be called. However, I can describe them. The three functions would take two arguments; a player, and a vector representing a position in the world.

The first function would return a boolean based on whether or not the position is within the player’s line of sight, ie. unobstructed by walls or entities. It would still return true if the point was behind the player, but unobstructed.
The second one would return a boolean whether or not the position is within the player’s view cone, and in turn, possibly visible on their screen. This is separate from the above function, as it would still return true if the point was obstructed.
The third would return the exact xy pixel position on the player’s screen that the point is rendered at. This could return negative values or values greater than the screen resolution if the position is off of the player’s screen.

For one, do any of these functions already exist? And if not, how would I implement any of them?

The first one can be done with


The second one can be done with

Vector:Dot and some math on the view angles. There are quite a few ways to do it though see this google query

The third one is


Thank you, although your description of how to implement the second function is fairly vague. I’ll look into how I could implement the first one.

[editline]15th April 2015[/editline]

I just looked at the documentation for

Vector:ToScreen, and it seems that the answer to my second function is contained within its return value in the ToScreenData structure:

[editline]15th April 2015[/editline]

Here’s the implementation of the first function I came up with;

function unobstructed( ply, pos )
return util.TraceLine({
start = ply:EyePos(),
endpos = pos
}).Fraction >= 0.999 – to account for small inaccuracies and edge cases

Is it suitable?