{"id":21325853,"url":"https://github.com/maxkapur/param_tools","last_synced_at":"2025-06-12T03:09:29.873Z","repository":{"id":118697442,"uuid":"272113530","full_name":"maxkapur/param_tools","owner":"maxkapur","description":"Integrate and generate random points over parametric curves and surfaces.","archived":false,"fork":false,"pushed_at":"2020-06-18T03:57:01.000Z","size":1698,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T11:21:16.499Z","etag":null,"topics":["integration","numerical-methods","numpy","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxkapur.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-14T01:31:56.000Z","updated_at":"2024-09-06T07:46:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"f492c956-c5f5-443d-a443-2e55a7218786","html_url":"https://github.com/maxkapur/param_tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkapur%2Fparam_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkapur%2Fparam_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkapur%2Fparam_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkapur%2Fparam_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxkapur","download_url":"https://codeload.github.com/maxkapur/param_tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975716,"owners_count":21192275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration","numerical-methods","numpy","python"],"created_at":"2024-11-21T21:07:45.034Z","updated_at":"2025-04-14T23:21:51.880Z","avatar_url":"https://github.com/maxkapur.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This module contains several functions useful for evaluating integrals and generating random points on parametric curves and surfaces.\n\nAuthor: [Max Kapur](maxkapur.com)\n\n### Examples\n\nGenerate uniformly distributed random points along a parametric curve:\n\n![spiral](spiral.png)\n\nGenerate uniformly distributed random points on a parametric surface:\n\n![wave](wave.png)\n\nPlease see the Jupyter notebook `examples.ipynb` or its HTML counterpart for workflow examples.\n\n### Calculating arc lengths and surface areas\n\n`arc_cumulator()` and `surface_cumulator()` take data coordinates as input and return the arc length or area accumulated at each point. If the parameterizing function is known, the convenience functions `arc_length()` and `surface_area()` return the total arc length or surface area over the given region. The precision arguments to `arc_length()` and `surface_area()` determine how many subintervals will be evaluated.\n\n### Generating random data\n\nThe functions `r_arc()` and `r_surface()`, and their counterparts `r_arc_from_data()` and `r_surface_from_data()`, let you generate random points that are uniformly distributed with respect to the arc length of a parametric curve or the area of a parametric surface.\n\nFor a curve given by a parametric function `func(t)` for a certain range of t-values, use `r_arc(n, func, t0, t1)`. For a surface given by a parametric function `func(t,u)` for a range of t- and u-values, use `r_surface(n, func, t0, t1, u0, u1)`.  The parameter space must be rectangular.\n\nFor a curve given by a list of point coordinates and (optionally) corresponding t-values, use `r_arc_from_data(n, t, coords)`. For a curve given by a grid of point coordinates and (optionally) corresponding t- and u-values, use `r_surface_from_data(n, t, u, coords)`, where the input is best formatted like a numpy meshgrid. In these functions, Scipy's interpolation functions are used to return points on the surface; the interpolation method may be controlled by the `kind` parameter.\n\nMathematically, the procedure for sampling a random point on an arc given by `f(t)` on `[t0, t1]` is as follows: \n\n 1. Numerically compute the total arc length `P`.\n 2. Pick a random number `s` on `[0, P)`. \n 3. Determine, by interpolation, `t` such that the arc length on `[t0, t]` is `s`.\n 4. Return `f(t)`.\n \nFor a surface given by `f(t, u)`, the process is similar: \n\n 1. Numerically compute the total area `A`. \n 2. Independently pick two random numbers `S1` and `S2` on `[0, A)`.\n 3. Determine, by interpolation, t such that the surface area on `[t0, t], [u0, u1]` is `S1`.\n 4. Determine, by interpolation, u such that the surface area on `[t0, t1], [u0, u]` is `S2`.\n 5. Return `f(t, u)`.\n \n### Acknowledgements\nThe following Stack Exchange discussions were of assistance in creating this module:\n\n - [Generate random points on perimeter of ellipse](https://math.stackexchange.com/questions/3710402/generate-random-points-on-perimeter-of-ellipse/3718774#3718774) (Math SE)\n - [Generate random points on perimeter of ellipse](https://codereview.stackexchange.com/questions/243590/generate-random-points-on-perimeter-of-ellipse/243697?noredirect=1#comment478326_243697) (Code Review SE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxkapur%2Fparam_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxkapur%2Fparam_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxkapur%2Fparam_tools/lists"}