类名 common/util/MathUtil.js
/**
 * 计算X、Y、Z的平方和并返回
 * @param {Point} point 点对象
 * @returns {Number} 平方和
 */
function magnitudeSquared(point) {
  // 如果有z值
  if (point.hasZ) {
    return (
      point.coordinates[0] * point.coordinates[0] +
      point.coordinates[1] * point.coordinates[1] +
      point.coordinates[2] * point.coordinates[2]
    )
  }
  return (
    point.coordinates[0] * point.coordinates[0] +
    point.coordinates[1] * point.coordinates[1]
  )
}

/**
 * 进行开根号计算
 * @param {Point} point 点对象
 * @returns {Number} 开根号后的值
 */
function magnitude(point) {
  return Math.sqrt(magnitudeSquared(point))
}

/**
 * 归一化计算
 * @param {Point} point 点对象
 * @returns {Object} 归一化后的值
 */
function normalize(point) {
  const result = point.clone()
  // 开根号计算
  const magnitude1 = magnitude(result)
  result.coordinates[0] /= magnitude1
  result.coordinates[1] /= magnitude1
  if (result.hasZ) {
    result.coordinates[2] /= magnitude1
  }
  return result
}

export { normalize }
构造函数
成员变量
方法
事件