github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/num/quat/util.go (about)

     1  // Copyright ©2018 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Copyright 2017 The Go Authors. All rights reserved.
     6  // Use of this source code is governed by a BSD-style
     7  // license that can be found in the LICENSE file.
     8  
     9  package quat
    10  
    11  func lift(v float64) Number {
    12  	return Number{Real: v}
    13  }
    14  
    15  func split(q Number) (float64, Number) {
    16  	return q.Real, Number{Imag: q.Imag, Jmag: q.Jmag, Kmag: q.Kmag}
    17  }
    18  
    19  func join(w float64, uv Number) Number {
    20  	uv.Real = w
    21  	return uv
    22  }
    23  
    24  func unit(q Number) Number {
    25  	return Scale(1/Abs(q), q)
    26  }