Jakub, The documentation for creating user-defined functions is at <http://www.sqlite.org/capi3.html>. See section 2.3. Unfortunately, I don't know the A,B of C, so I can't guide you in this. On the other hand, if you are using Perl, I can write you a step-by-step process for creating your own functions -- it takes about 2 lines of code. If you know C, the above mentioned documentation should point you in the right direction.
In any case, Dennis Cote's suggestion is really fantastic. You don't need the trig functions to solve your existing problem. Use those suggestions and you will be well on your way. On 3/9/07, Jakub Ladman <[EMAIL PROTECTED]> wrote:
Thank you very much. Not only my english is poor, but my coordinated geometry too :-( But my software will make much more geometrical computations, so probably some in queries too. Please let You (or someone) direct me to the relevant part of documentation for defining new functions. Thank You Jakub Dne pátek 09 březen 2007 23:35 Dennis Cote napsal(a): > 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] > --------------------------------------------------------------------------- >-- ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------
-- Puneet Kishor http://punkish.eidesis.org/ Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/ Open Source Geospatial Foundation http://www.osgeo.org/education/ --------------------------------------------------------------------- collaborate, communicate, compete =====================================================================