User Tag List

Results 1 to 2 of 2

Thread: Geometry question.

  1. #1
    No Products Registered

    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Geometry question.

    Hey everyone.

    I have a question that I've been wrestling with for a while. I know how to determine whether a point lies within a circle through usage of the circle's equation.

    However, I have no idea how to determine whether a particular point lies within a certain sector of said circle.

    Example -

    I am working on a tower defense game based around detectors and reactors (detectors detects enemies and reactors deal with enemies). One of my towers is a security camera if I wanted this tower to have 360 degrees of vision I would take the point of the enemy, in relation to the tower and plug it into the circle equation.and I don't want this tower to have 360 degrees of vision. In fact I want it to only detect enemies in a quadrant of it's circle, with the potential to increase this number through upgrades - up to 110 degrees or so.

    Is there an equation that deals with this? If not, how would I go about solving this conundrum?

    Thanks.

  2. #2
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Århus
    Posts
    3,456
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    The circle's equation only determines if a point lies directly on the edge of the circle, not within it.

    To solve your problem simply calculate the distance from the circle's center to your point. If that distance is less or equal to the radius then you are within range.
    The Advanced Direction object has a handy expression to get the distance between two points easily.

    You then need to figure out if the 'angular distance' between the current viewing angle of the tower and the object in question is too great.
    The Advanced Direction also has a handy expression to get the angle between two points AND the difference between two angles/directions.

    That looks like all you need to make your game

Similar Threads

  1. Geometry War
    By CADMAN in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 23rd April 2010, 03:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •