The method Vector3.Normalize()has a pointer receiver, so calling this method requires a pointer to the value Vector3( *Vector3). In the first example, you store the return value Vector3.Minus()in a variable that will be of type Vector3.
Go , diff.Normalize(), , diff, *Vector3, Normalize(). ""
(&diff).Normalize()
Spec: Calls:
x.m() , () x m, m. x &x m, x.m() (&x).m().
, , , , , Vector3.Minus().
, , Spec: :
, , , ; ; . x [ &x] (, ) .
. :
?
Go?
" "
" " ( ) - . .
- , ( ), , " ". , , , , ( , , ), , ).
- (*Vector3) Vector3. , , , .
, . :
func pv(v Vector3) *Vector3 {
return &v
}
:
dir := pv(projected.Minus(c.Origin)).Normalize()
Vector3, :
func (v Vector3) pv() *Vector3 {
return &v
}
:
dir := projected.Minus(c.Origin).pv().Normalize()
:
3 float64 , . . , . , .