{"id":16836909,"url":"https://github.com/fil/attitude","last_synced_at":"2025-03-22T04:30:56.424Z","repository":{"id":47439560,"uuid":"233933379","full_name":"Fil/attitude","owner":"Fil","description":"Attitude: orientation of an object in space.","archived":false,"fork":false,"pushed_at":"2023-07-18T21:04:16.000Z","size":157,"stargazers_count":34,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-11T20:51:16.338Z","etag":null,"topics":["attitude","d3js","euler-angles","geo","rotation","rotation-matrix","rotation-vectors","slerp","unit-quaternion","versor"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-01-14T20:51:28.000Z","updated_at":"2024-11-07T01:00:06.000Z","dependencies_parsed_at":"2024-10-28T12:46:12.124Z","dependency_job_id":null,"html_url":"https://github.com/Fil/attitude","commit_stats":{"total_commits":51,"total_committers":2,"mean_commits":25.5,"dds":"0.039215686274509776","last_synced_commit":"d8ef439ac86c4de4369bfb344924e4ec9f4288a6"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fattitude","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fattitude/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fattitude/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fattitude/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fil","download_url":"https://codeload.github.com/Fil/attitude/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244907420,"owners_count":20529850,"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":["attitude","d3js","euler-angles","geo","rotation","rotation-matrix","rotation-vectors","slerp","unit-quaternion","versor"],"created_at":"2024-10-13T12:15:19.818Z","updated_at":"2025-03-22T04:30:56.143Z","avatar_url":"https://github.com/Fil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# attitude\n\n_Attitude: orientation of an object in space._\n\nA rotation of the sphere can be represented in various ways, such as:\n\n- [Euler Angles](#euler-angles)\n- [Axis-Angle](#axis-angle)\n- [Rotation Matrix](#rotation-matrix)\n- [Unit Quaternion](#unit-quaternion) (aka versor)\n- [Rotation Vector](#rotation-vector)\n\nThe **attitude** module allows conversions and computations between all these representations.\n\nSee https://observablehq.com/@fil/attitude for details.\n\n\n## Installing\n\nIf you use NPM, `npm install attitude`. Otherwise, download the [latest release](https://github.com/Fil/attitude/releases/latest). AMD, CommonJS, and vanilla environments are supported. In vanilla, an `attitude` global is exported:\n\n```html\n\u003cscript src=\"https://unpkg.com/attitude\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\nconst attitude = attitude();\n\n\u003c/script\u003e\n```\n\n[Try attitude in your browser.](https://observablehq.com/collection/@fil/attitude)\n\n\n## Representations\n\n\n### Euler Angles\n\n`[lambda, phi, gamma]`, in degrees.\n\n### Axis-Angle\n\n`{ axis: [lon, lat], angle: alpha }`, in degrees.\n\n### Rotation Matrix\n\n~~~{js}\n[ [r11, r12, r13],\n  [r21, r22, r23],\n  [r31, r32, r33] ]\n~~~\n\n### Unit Quaternion\n\n`q = [q0, q1, q2, q3, q4]` is also called a *versor* when its norm is equal to 1.\n\n### Rotation Vector\n\n`[ x, y, z ]` = *f(a)B*, where *f(a)* is a scalar encoding the angle, and *B* a unit vector in cartesian coordinates.\n\n*Note:* there are many ways to encode the angle, we have to settle on a default. The useful functions *f(a)* are:\n- *tan(a/4)*: stereographic, ‘Modified Rodrigues Parameters’.\n- *tan(a/2)*: gnomonic, ‘Rodrigues Parameters’, ‘Gibbs vector’.\n- *a*: equidistant, logarithm vector.\n- (vector part of the) unit quaternion: Euler angles.\n\nDefaults to the stereographic vector representation.\n\n\n## API Reference\n\n\u003ca name=\"attitude\" href=\"#attitude\"\u003e#\u003c/a\u003e attitude([\u003ci\u003eangles\u003c/i\u003e])\n\nReturns an *attitude* object. Sets the rotation’s Euler angles if the *angles* argument is specified. *attitude* is equivalent to [d3.geoRotation(angles)](https://github.com/d3/d3-geo/blob/master/README.md#geoRotation), and can be used as a function to rotate a point [longitude, latitude]. \n\n### Operations\n\n\u003ca name=\"attitude_invert\" href=\"#attitude_invert\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003einvert\u003c/b\u003e(\u003ci\u003epoint\u003c/i\u003e)\n\nReturns the *inverse* rotation of the point.\n\n\u003ca name=\"attitude_inverse\" href=\"#attitude_inverse\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003einverse\u003c/b\u003e()\n\nReturns a new attitude, inverse of the original.\n\n\u003ca name=\"attitude_compose\" href=\"#attitude_compose\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003ecompose\u003c/b\u003e(\u003ci\u003eb\u003c/i\u003e)\n\nReturns a new attitude, composition of the original with the argument. When *c* = *a*.compose(*b*) is applied to a point *p*, the result *c*(*p*) = *a*(*b*(*p*)): in other words, the rotation *b* will be applied first, then rotation *a*.\n\n\u003ca name=\"attitude_power\" href=\"#attitude_power\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003epower\u003c/b\u003e(\u003ci\u003epower\u003c/i\u003e)\n\nReturns a new partial attitude. *a*.power(2) is twice the rotation *a*, *a*.power(.5) is half the rotation *a*.\n\n\u003ca name=\"attitude_arc\" href=\"#attitude_arc\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003earc\u003c/b\u003e(\u003ci\u003eA\u003c/i\u003e, \u003ci\u003eB\u003c/i\u003e)\n\nReturns a new attitude that brings the point *A* to *B* by the shortest (geodesic) path.\n\n\u003ca name=\"attitude_interpolateTo\" href=\"#attitude_interpolateTo\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003einterpolateTo\u003c/b\u003e(\u003ci\u003eb\u003c/i\u003e)\n\nReturns an interpolator that continuously transitions the original *attitude* to the argument. The result is a function of *t* that is equivalent to *attitude* for *t* = 0, and equivalent to *b* for *t* = 1. Useful for [spherical linear interpolation (SLERP)](https://observablehq.com/d/b3c52ccf8f22ef2b?collection=@fil/attitude).\n\n\n### Representations\n\n\u003ca name=\"attitude_angles\" href=\"#attitude_angles\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003eangles\u003c/b\u003e([\u003ci\u003eangles\u003c/i\u003e])\n\nSets or reads the *Euler angles* of an *attitude*, as an array [\u0026phi;, \u0026lambda;, \u0026gamma;] (in degrees).\n\n\u003ca name=\"attitude_axis\" href=\"#attitude_axis\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003eaxis\u003c/b\u003e([\u003ci\u003eaxis\u003c/i\u003e])\n\nSets or reads the *rotation axis* of an *attitude*, as [lon, lat] coordinates.\n\n\u003ca name=\"attitude_angle\" href=\"#attitude_angle\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003eangle\u003c/b\u003e([\u003ci\u003eangle\u003c/i\u003e])\n\nSets or reads the *rotation angle* of an *attitude*, in degrees.\n\n\u003ca name=\"attitude_versor\" href=\"#attitude_versor\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003eversor\u003c/b\u003e([\u003ci\u003eversor\u003c/i\u003e])\n\nSets or reads the *versor* representation of an *attitude*, as a length-4 array.\n\n\u003ca name=\"attitude_matrix\" href=\"#attitude_matrix\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003ematrix\u003c/b\u003e([\u003ci\u003ematrix\u003c/i\u003e])\n\nSets or reads the *matrix* representation of an *attitude*, as a matrix of size 3\u0026times;3.\n\n\u003ca name=\"attitude_vector\" href=\"#attitude_vector\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003evector\u003c/b\u003e([\u003ci\u003evector\u003c/i\u003e])\n\nSets or reads the *vector* representation of an *attitude*, as a length-3 array. That array can be written f(a)B, where f is a function of the rotation’s angle, and B a unit vector respresenting the axis in cartesian coordinates.\n\nDefaults to the [stereographic](#attitude_vectorStereographic) vector: f(a) = tan(a/4).\n\n\u003ca name=\"attitude_vectorStereographic\" href=\"#attitude_vectorStereographic\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003evectorStereographic\u003c/b\u003e([\u003ci\u003evector\u003c/i\u003e])\n\n*Stereographic* vector: f(a) = tan(a/4). Also called the ‘Modified Rodrigues Parameters’.\n\n\u003ca name=\"attitude_vectorGnomonic\" href=\"#attitude_vectorGnomonic\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003evectorGnomonic\u003c/b\u003e([\u003ci\u003evector\u003c/i\u003e])\n\n*Gnomonic* vector: f(a) = tan(a/2). Also called ‘Rodrigues Parameters’ or ‘Gibbs vector’.\n\n\u003ca name=\"attitude_vectorEquidistant\" href=\"#attitude_vectorEquidistant\"\u003e#\u003c/a\u003e *attitude*.\u003cb\u003evectorEquidistant\u003c/b\u003e([\u003ci\u003evector\u003c/i\u003e])\n\n*Equidistant* vector: f(a) = a. Also called the logarithm vector.\n\n\n\n---\n\nWith thanks to [Jacob Rus](https://observablehq.com/@jrus), [Nadieh Bremer](https://www.visualcinnamon.com), [Mike Bostock](https://bost.ocks.org/mike/) and [Darcy Murphy](https://github.com/mrDarcyMurphy).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffil%2Fattitude","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffil%2Fattitude","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffil%2Fattitude/lists"}