ee.Number.hypot
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Calculates the magnitude of the 2D vector [x, y].
שימוש | החזרות |
---|
Number.hypot(right) | מספר |
ארגומנט | סוג | פרטים |
---|
זה: left | מספר | הערך בצד ימין. |
right | מספר | הערך בצד שמאל. |
דוגמאות
עורך הקוד (JavaScript)
// Left input is x and right input is y, representing point (x,y).
print('Length from origin to point (0,0)', ee.Number(0).hypot(0)); // 0
print('Length from origin to point (3,0)', ee.Number(3).hypot(0)); // 3
print('Length from origin to point (3,4)', ee.Number(3).hypot(4)); // 5
print('Length from origin to point (-3,4)', ee.Number(-3).hypot(4)); // 5
print('Length from origin to point (-3,-4)', ee.Number(-3).hypot(-4)); // 5
הגדרת Python
מידע על Python API ועל שימוש ב-geemap
לפיתוח אינטראקטיבי מופיע בדף
Python Environment.
import ee
import geemap.core as geemap
Colab (Python)
# Left input is x and right input is y, representing point (x,y).
# 0
print('Length from origin to point (0,0):', ee.Number(0).hypot(0).getInfo())
# 3
print('Length from origin to point (3,0):', ee.Number(3).hypot(0).getInfo())
# 5
print('Length from origin to point (3,4):', ee.Number(3).hypot(4).getInfo())
# 5
print('Length from origin to point (-3,4):', ee.Number(-3).hypot(4).getInfo())
# 5
print('Length from origin to point (-3,-4):', ee.Number(-3).hypot(-4).getInfo())
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון 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,["# ee.Number.hypot\n\nCalculates 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--------\n\n### Code 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\n### Colab (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```"]]