---
title: Tuple, Vector and Pointer
---
classDiagram
note "Legend:
+ Public
- Private
# Protected
~ Package/Internal
$ Static
* Abstract
<|-- Inheritance
*-- Composition
o-- Aggregation
--> Association
-- Link (Solid)
..> Dependency
..|> Realization
.. Link (Dashed)"
class Tuple{
+float x
+float y
+float z
+float w
+Add()
+Negate()
}
%% note for Vector "Note: w is 0"
Tuple --|> Vector : Inheritance
class Vector{
float w$=0
-Dot()
-Cros()
}
%% note for Pointer "Note: w is 1"
Tuple --|> Point : Inheritance
class Point{
float w$=1
}
- Vector + Vector => Vector
- Vector + Point => Point
- NO ALLOWED: Point + Point => (w=2)
- Vector - Vector => Vector
- Point - Vector => Point
- NOT ALLOWED: Vector - Point => (w=-1)
- (x, y, z, w) => (-x, -y, -z, -w)
- s * (x, y, z, w) => (sx, sy, sz, sw)
- (x, y, z, w) / s => (x/s, y/s, z/s, w/s)
- |v| = sqrt(x^2, y^2, z^2, w^2), where w = 0, i.e. vector
- (x/|v|, y/|v|, z|v|, w/|v|)
- (vector1, vector2) => scalar, i.e. x1 * x2 + y1y2 + z1z2 + w1*w2
- (vector1, vector2) => (vector3)
- i.e. (a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x)
Generate a new test suite in the current directory:
cd path/to/books
ginkgo bootstrap
- Run the tests in the current directory:
ginkgo
- Run all tests for the project:
go run github.com/onsi/ginkgo/v2/ginkgo -r --randomize-all --randomize-suites --fail-on-pending --keep-going --cover --coverprofile=cover.profile --race --trace --json-report=report.jso
This will generate a test file named book_test.go in the books directory:
```shell
ginkgo generate book