Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eNumber.hypot()\u003c/code\u003e calculates the magnitude (or length) of a 2D vector defined by coordinates \u003ccode\u003ex\u003c/code\u003e (left input) and \u003ccode\u003ey\u003c/code\u003e (right input).\u003c/p\u003e\n"],["\u003cp\u003eIt effectively computes the distance from the origin (0,0) to the point (x,y) in a 2D plane.\u003c/p\u003e\n"],["\u003cp\u003eThe result returned is a number representing the calculated magnitude/distance.\u003c/p\u003e\n"],["\u003cp\u003eExamples demonstrate its usage with various coordinate combinations, illustrating consistent magnitude calculation regardless of sign.\u003c/p\u003e\n"]]],["The `hypot` method calculates the magnitude of a 2D vector. It takes two numeric arguments, `left` (x-value) and `right` (y-value), and returns a `Number` representing the distance from the origin (0,0) to the point (x,y). The examples demonstrate that inputs of (0,0), (3,0), (3,4), (-3,4), and (-3,-4) result in magnitudes of 0, 3, 5, 5, and 5, respectively. The function is available in both JavaScript and Python.\n"],null,["Calculates the magnitude of the 2D vector \\[x, y\\].\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------|---------|\n| Number.hypot`(right)` | Number |\n\n| Argument | Type | Details |\n|--------------|--------|-----------------------|\n| this: `left` | Number | The left-hand value. |\n| `right` | Number | The right-hand value. |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\n// Left input is x and right input is y, representing point (x,y).\nprint('Length from origin to point (0,0)', ee.Number(0).hypot(0)); // 0\nprint('Length from origin to point (3,0)', ee.Number(3).hypot(0)); // 3\nprint('Length from origin to point (3,4)', ee.Number(3).hypot(4)); // 5\nprint('Length from origin to point (-3,4)', ee.Number(-3).hypot(4)); // 5\nprint('Length from origin to point (-3,-4)', ee.Number(-3).hypot(-4)); // 5\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\nColab (Python) \n\n```python\n# Left input is x and right input is y, representing point (x,y).\n# 0\nprint('Length from origin to point (0,0):', ee.Number(0).hypot(0).getInfo())\n# 3\nprint('Length from origin to point (3,0):', ee.Number(3).hypot(0).getInfo())\n# 5\nprint('Length from origin to point (3,4):', ee.Number(3).hypot(4).getInfo())\n# 5\nprint('Length from origin to point (-3,4):', ee.Number(-3).hypot(4).getInfo())\n# 5\nprint('Length from origin to point (-3,-4):', ee.Number(-3).hypot(-4).getInfo())\n```"]]