{ "info": { "author": "Christopher Knight", "author_email": "cosmologicon@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "# maff\nPython convenience functions that I wish were in the math module, as well as some that I agree\nprobably shouldn't be.\n\n## Quick usage\n\n\timport maff\n\tprint(maff.ease(0.1))\n\nThe first time you import `maff`, it will also pollute the `math` module with its own functions, so\nyou can call them via `math` on any module that imports `math`.\n\n\timport maff, math\n\tprint(math.ease(0.1))\n\n## To install\n\nDownload `maff.py` and put it in your source directory. To install from command line:\n\n\tcurl https://raw.githubusercontent.com/cosmologicon/maff/master/maff.py > my-source-directory/maff.py\n\n## Usage note\n\nAs the name hopefully implies, this is a bit of a frivolous module and not recommended for serious\nuse. I plan to use it for game jams.\n\n## Constants\n\n`maff.tau`: the circle constant equal to 2pi.\n\n`maff.phi` and `maff.Phi`: golden ratio and reciprocal golden ratio.\n\n## Functions taken from GLSL\n\n`maff.sign(x)`: sign of x.\n\n`maff.clamp(x, a, b)`: clamps x to range [a, b].\n\n`maff.mix(x, y, a)`: mix the values x and y with mixing factor a.\n\n`maff.step(edge, x)`: Heaviside step function of x with given edge.\n\n`maff.smoothstep(edge0, edge1, x)`: step function with Hermite interpolation between edge0 and edge1.\n\n`maff.length(v)`: length of vector v. Can be any iterable.\n\n`maff.distance(v0, v1)`: distance between vectors v0 and v1\n\n`maff.dot(v0, v1)`: dot product\n\n`maff.norm(v)` or `maff.normalize(v)`: normalize vector to length 1. Does not fail on zero vector.\n\n`maff.norm(v, a)` or `maff.normalize(v, a)`: normalize vector to length a.\n\n## Fade functions\n\n`maff.ease(x)`: Hermite interpolation of x in range (0, 1). Equal to `maff.smoothstep(0, 1, x)`.\n\n`maff.fade(x, x0, dx)`: fade from 0 to 1 starting at x = x0 for a fade interval of dx.\n\n`maff.smoothfade(x, x0, dx)`: like `fade` with Hermite interpolation.\n\n`maff.dfade(x, x0, x1, dx)`: double-fade from 0 to 1 starting at x0, then back from 1 to 0 ending at\nx1, with a fade interval of dx on both ends.\n\n`maff.dsmoothfade(x, x0, x1, dx)`: double-fade with Hermite interpolation.\n\n## Approach functions\n\n`maff.approach(x, y, dx)`: increase or decrease x by amount dx in the direction of y. If the\ndistance between x and y is less than dx, then return y instead. x and y can be vectors.\n\n`maff.softapproach(x, y, dlogx)`: increase or decrease x by an amount determined by dlogx. dlogx is\na unitless parameter between 0 and infinity. If dlogx is 0, then x will be returned. For\nsufficiently large dlogx, then y will be returned. Calling this repeatedly and updating the value of\nx will give exponential decay toward y, with a timescale factor of 1 / dlogx.\n\n`maff.softapproach(x, y, dlogx, dxmax=inf, dymin=0.1)`: After calculating the approach distance dx,\nit's compared with dxmax. If it exceeds dxmax then it's capped at dxmax. If the resulting is a\ndistance less than dymin away from y, then y is returned. This is because with exponential decay\nit's impossible to ever exactly reach y.\n\n## Other functions\n\n`maff.CS(theta)`: 2-tuple of cos(theta), sin(theta).\n\n`maff.CS(theta, r)`: 2-tuple of r cos(theta), r sin(theta).\n\n`maff.CSround(ntheta)`: Produces ntheta 2-tuples of cos(theta), sin(theta) distributed around the\nunit circle.\n\n`maff.CSround(ntheta, r=1, jtheta0=0)`: specify radius and offset.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cosmologicon/maff", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "maff", "package_url": "https://pypi.org/project/maff/", "platform": "", "project_url": "https://pypi.org/project/maff/", "project_urls": { "Homepage": "https://github.com/cosmologicon/maff" }, "release_url": "https://pypi.org/project/maff/0.1/", "requires_dist": null, "requires_python": "", "summary": "Python convenience functions that I wish were in the math module", "version": "0.1" }, "last_serial": 3059161, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "1f88661cdaf1bba8e959915d42b79389", "sha256": "d01384fcb53a35257c3c16dfb9dfb70638e8dd18c038f6296d00c0b4ca9181c6" }, "downloads": -1, "filename": "maff-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1f88661cdaf1bba8e959915d42b79389", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 5901, "upload_time": "2017-07-30T11:40:46", "url": "https://files.pythonhosted.org/packages/e6/32/cba911b907e9add4230a3f7d004950871ede15ec96fe3448fcff735bc96a/maff-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4aa7f5c9d324d0b02ee6c3555ceb0126", "sha256": "cecf9b6b4ecd1109bb9f3d4913e8a5d380ddcb11ed2e1978ba4574657cdd41d0" }, "downloads": -1, "filename": "maff-0.1.tar.gz", "has_sig": false, "md5_digest": "4aa7f5c9d324d0b02ee6c3555ceb0126", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3680, "upload_time": "2017-07-30T11:40:44", "url": "https://files.pythonhosted.org/packages/b9/cf/33eec3ca733167e74eb74f3bb29b1c68cd7872ee4396eb3c68cf7fe6eb44/maff-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1f88661cdaf1bba8e959915d42b79389", "sha256": "d01384fcb53a35257c3c16dfb9dfb70638e8dd18c038f6296d00c0b4ca9181c6" }, "downloads": -1, "filename": "maff-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1f88661cdaf1bba8e959915d42b79389", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 5901, "upload_time": "2017-07-30T11:40:46", "url": "https://files.pythonhosted.org/packages/e6/32/cba911b907e9add4230a3f7d004950871ede15ec96fe3448fcff735bc96a/maff-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4aa7f5c9d324d0b02ee6c3555ceb0126", "sha256": "cecf9b6b4ecd1109bb9f3d4913e8a5d380ddcb11ed2e1978ba4574657cdd41d0" }, "downloads": -1, "filename": "maff-0.1.tar.gz", "has_sig": false, "md5_digest": "4aa7f5c9d324d0b02ee6c3555ceb0126", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3680, "upload_time": "2017-07-30T11:40:44", "url": "https://files.pythonhosted.org/packages/b9/cf/33eec3ca733167e74eb74f3bb29b1c68cd7872ee4396eb3c68cf7fe6eb44/maff-0.1.tar.gz" } ] }