Jakub Ladman wrote:
I will have table with sequence of coordinates (two dimensional space) and corresponding radiuses, so sequence of circles. And i need to use a sqlite query to detect if a actual coordinates (after their measurement) match some of the circle's square or not. And which circle, if match. And this must be for low CPU consumption optimised, so i am not sure, if separate sin table queries will be enough as fast as i need at needed precission.

The whole algorithm is proven on mssql by my colegue, but he is using the native math functions.

Jakub,

I may not understand your problem completely, but it seems to me you can solve your problem without using any trigonometric functions.

If you have a table of circles like this

   create table circle (
       id  integer primary key,
       cx  real,
       cy  real,
       r   real
   );

You can find all the circles that contain a given point (px,py) using a simple query based in the distance between the point and the center of the circle.

   select id from circle
   where (px-cx)*(px-cx)+(py-cy)*(py-cy) < r*r;

If you want to create a user defined distance function you could possibly speed up the calculation somewhat. You could then use a query like:

   select id from circle
   where distance(cx, cy, px, py) < r;

where

distance(cx, cy, px, py) = sqrt((px-cx)^2 + (py-cy)^2)
HTH
Dennis Cote
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to