Pengumuman: Semua project nonkomersial yang terdaftar untuk menggunakan Earth Engine sebelum
15 April 2025 harus
memverifikasi kelayakan nonkomersial untuk mempertahankan akses Earth Engine.
ee.Number.hypot
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menghitung besarnya vektor 2D [x, y].
Penggunaan | Hasil |
---|
Number.hypot(right) | Angka |
Argumen | Jenis | Detail |
---|
ini: left | Angka | Nilai sebelah kiri. |
right | Angka | Nilai sebelah kanan. |
Contoh
Code Editor (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
Penyiapan Python
Lihat halaman
Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan
geemap
untuk pengembangan interaktif.
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())
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-26 UTC.
[null,null,["Terakhir diperbarui pada 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```"]]