當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Processing PVector.dist()用法及代碼示例

Processing, 類PVector中的dist()用法介紹。

用法

  • .dist(v)
  • .dist(v1, v2)

參數

  • v (PVector) PVector 的 x、y 和 z 坐標
  • v1 (PVector) PVector 類型的任何變量
  • v2 (PVector) PVector 類型的任何變量

返回

  • float

說明

計算兩點之間的歐幾裏得距離(將點視為矢量對象)。

例子

PVector  v1 = new PVector(10, 20, 0);
PVector  v2 = new PVector(60, 80, 0); 
float d = v1.dist(v2);
println(d);  // Prints "78.10249"
PVector  v1 = new PVector(10, 20, 0);
PVector  v2 = new PVector(60, 80, 0); 
float d = PVector.dist(v1, v2);
println(d);  // Prints "78.10249"

相關用法


注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 PVector.dist()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。