read3BitNormal reads a normalized float vector
()
| 359 | |
| 360 | // read3BitNormal reads a normalized float vector |
| 361 | func (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 |
| 392 | func (r *reader) readBitsAsBytes(n uint32) []byte { |
no test coverage detected