MCPcopy Create free account
hub / github.com/dotabuff/manta / read3BitNormal

Method read3BitNormal

reader.go:361–389  ·  view source on GitHub ↗

read3BitNormal reads a normalized float vector

()

Source from the content-addressed store, hash-verified

359
360// read3BitNormal reads a normalized float vector
361func (r *reader) read3BitNormal() []float32 {
362 ret := []float32{0.0, 0.0, 0.0}
363
364 hasX := r.readBoolean()
365 haxY := r.readBoolean()
366
367 if hasX {
368 ret[0] = r.readNormal()
369 }
370
371 if haxY {
372 ret[1] = r.readNormal()
373 }
374
375 negZ := r.readBoolean()
376 prodsum := ret[0]*ret[0] + ret[1]*ret[1]
377
378 if prodsum < 1.0 {
379 ret[2] = float32(math.Sqrt(float64(1.0 - prodsum)))
380 } else {
381 ret[2] = 0.0
382 }
383
384 if negZ {
385 ret[2] = -ret[2]
386 }
387
388 return ret
389}
390
391// readBitsAsBytes reads the given number of bits in groups of bytes
392func (r *reader) readBitsAsBytes(n uint32) []byte {

Callers 1

vectorNormalDecoderFunction · 0.80

Calls 2

readBooleanMethod · 0.95
readNormalMethod · 0.95

Tested by

no test coverage detected