Documentation
¶
Overview ¶
Copyright 2025 César Nieto Sánchez
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025 César Nieto Sánchez ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025 César Nieto Sánchez ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Line ¶
type Line struct {
Point1 *Point // Starting point of the line
Point2 *Point // Ending point of the line
}
Line represents a line in 2D space defined by two points (Point1 and Point2).
func NewLine ¶
NewLine creates a new Line instance.
Arguments:
pa (*Point): The first point defining the line. pb (*Point): The second point defining the line.
Returns:
*Line: A pointer to the newly created Line object.
func (Line) Dimension ¶
Dimension returns the dimension of the line.
Returns:
int: The dimension of the line.
func (Line) Length ¶
Length calculates the length of the line.
The length is computed as the norm of the direction vector.
Returns:
float64: The length of the line.
func (Line) String ¶
String returns a string representation of the Line object.
Returns:
string: A string representation of the Line object.
func (Line) VectorDirector ¶
VectorDirector calculates the direction vector of the line.
The direction vector is computed as the difference between Point2 and Point1.
Returns:
*Vector2D: A pointer to a Vector2D representing the direction of the line.
type Point ¶
Point represents a point in an n-dimensional space.
This struct wraps a `gonum` VecDense to provide additional functionality for representing and manipulating points in n-dimensional geometry.
func NewPoint ¶
NewPoint creates a new Point instance.
Arguments:
coordinates ([]float64): A slice of float64 values representing the coordinates of the point.
Returns:
*Point: A pointer to the newly created Point instance.
Example:
// Create a 3D point with coordinates (1.0, 2.0, 3.0):
point := NewPoint([]float64{1.0, 2.0, 3.0})
func (Point) Dimension ¶
Dimension returns the dimension of the point.
This method retrieves the length of the underlying vector, which corresponds to the number of dimensions of the point.
Returns:
int: The number of dimensions of the point.
Example:
point := NewPoint([]float64{1.0, 2.0, 3.0})
fmt.Println(point.Dimension()) // Output: 3
type Vector ¶
Vector represents a vector, which is a mathematical entity defined by its components.
func NewVector ¶
NewVector creates a new Vector instance.
Arguments:
- coordinates ([]float64): A slice of float64 values representing the vector's components.
Returns:
- *Vector: A pointer to the newly created Vector.
func NewVectorTwoPoints ¶
NewVectorTwoPoints creates a vector from two points.
Arguments:
- p1 (*Point): The starting point of the vector.
- p2 (*Point): The ending point of the vector.
Returns:
- *Vector: A pointer to the newly created Vector representing the difference between p2 and p1.
Panics:
- If the dimensions of p1 and p2 are not equal.
func (Vector) Dimension ¶
Dimension returns the dimension (number of components) of the vector.
Returns:
- int: The dimension of the vector.