Documentation ¶
Overview ¶
Package types implements the base types that the renderer uses
Index ¶
- func GetCosineSimilarity(p1, p2, p3 Vector2d) float64
- type Circle
- func (cir *Circle) Render() ([]Vector2d, error)
- func (cir *Circle) RotateAbout(vec Vector2d, angleRads float64)
- func (cir *Circle) RotateAboutCenter(float64)
- func (cir *Circle) Scale(scaleFactor float64)
- func (cir *Circle) ScaleX(float64)
- func (cir *Circle) ScaleXY(float64, float64)
- func (cir *Circle) ScaleY(float64)
- func (cir *Circle) Translate(vec Vector2d)
- type NPoly
- func (np *NPoly) GetTriangles() []Triangle
- func (np *NPoly) Render() ([]Vector2d, error)
- func (np *NPoly) RenderComposite() ([][]Vector2d, error)
- func (np *NPoly) RotateAbout(vec Vector2d, angleRads float64)
- func (np *NPoly) RotateAboutCenter(angleRads float64)
- func (np *NPoly) Scale(scaleFactor float64)
- func (np *NPoly) ScaleX(scaleFactor float64)
- func (np *NPoly) ScaleXY(scaleFactorX float64, scaleFactorY float64)
- func (np *NPoly) ScaleY(scaleFactor float64)
- func (np *NPoly) Translate(vec Vector2d)
- type Obj2D
- type Obj3D
- type Quad
- func (q *Quad) GetTriangles() []Triangle
- func (q *Quad) Render() ([]Vector2d, error)
- func (q *Quad) RotateAbout(vec Vector2d, angleRads float64)
- func (q *Quad) RotateAboutCenter(angleRads float64)
- func (q *Quad) Scale(scaleFactor float64)
- func (q *Quad) ScaleX(scaleFactor float64)
- func (q *Quad) ScaleXY(scaleFactorX float64, scaleFactorY float64)
- func (q *Quad) ScaleY(scaleFactor float64)
- func (q *Quad) Translate(vec Vector2d)
- type Renderable
- type RenderableComposite
- type Triangle
- func (t *Triangle) Render() ([]Vector2d, error)
- func (t *Triangle) RotateAbout(vec Vector2d, angleRads float64)
- func (t *Triangle) RotateAboutCenter(angleRads float64)
- func (t *Triangle) Scale(scaleFactor float64)
- func (t *Triangle) ScaleX(scaleFactorX float64)
- func (t *Triangle) ScaleXY(scaleFactorX float64, scaleFactorY float64)
- func (t *Triangle) ScaleY(scaleFactorY float64)
- func (t *Triangle) Translate(vec Vector2d)
- type Vector2d
- func (v2d *Vector2d) GetAbs() float64
- func (v2d *Vector2d) GetDotProduct(vector Vector2d) float64
- func (v2d *Vector2d) GetRelativeCoords(point Vector2d) Vector2d
- func (v2d *Vector2d) Render() ([]Vector2d, error)
- func (v2d *Vector2d) RotateAbout(point Vector2d, angleRads float64)
- func (v2d *Vector2d) RotateAboutCenter(angleRads float64)
- func (v2d *Vector2d) Scale(scaleFactor float64)
- func (v2d *Vector2d) ScaleX(scaleFactor float64)
- func (v2d *Vector2d) ScaleXY(scaleFactorX float64, scaleFactorY float64)
- func (v2d *Vector2d) ScaleY(scaleFactor float64)
- func (v2d *Vector2d) Translate(translate Vector2d)
- type Vector3d
- func (v3d *Vector3d) GetRelativeCoords3D(point Vector3d) Vector3d
- func (v3d *Vector3d) RotateAbout3D(point, amounts Vector3d)
- func (v3d *Vector3d) RotateAboutCenter3D(ret Vector3d)
- func (v3d *Vector3d) RotateAboutX(degRads float64)
- func (v3d *Vector3d) RotateAboutY(degRads float64)
- func (v3d *Vector3d) RotateAboutZ(degRads float64)
- func (v3d *Vector3d) Scale3D(scaleFactor float64)
- func (v3d *Vector3d) ScaleXYZ(scaleX, scaleY, scaleZ float64)
- func (v3d *Vector3d) ScaleXZ(scaleX, scaleZ float64)
- func (v3d *Vector3d) ScaleYZ(scaleY, scaleZ float64)
- func (v3d *Vector3d) Translate3D(vector Vector3d)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCosineSimilarity ¶
GetCosineSimilarity gets the cosine similarity between two vectors P1 is end 1 P2 is the pivot point P3 is end 2
Types ¶
type Circle ¶
Circle is a 2D Circle, it stores the Center and the Radius
func (*Circle) Render ¶
Render returns a slice containing the points on the perimeter of the circle It's mildly complex with a circle, check the link in the code for how it works
func (*Circle) RotateAbout ¶
RotateAbout rotates about an arbitrary point
func (*Circle) RotateAboutCenter ¶
RotateAboutCenter does nothing
type NPoly ¶
type NPoly struct { // each point is connected to the next and the last is connected to the 0th one Points []Vector2d `json:"Points"` }
func (*NPoly) GetTriangles ¶
GetTriangles decomposes a shape into it's composite triangles
func (*NPoly) RenderComposite ¶
RenderComposite renders the NPoly as a collection of triangles as opposed to one Polygon, this is good for more complex draws
func (*NPoly) RotateAbout ¶
RotateAbout rotates all points around some arbitrary point by some magnitude
func (*NPoly) RotateAboutCenter ¶
RotateAboutCenter rotates about the center of a polygon
type Obj2D ¶
type Obj2D interface { Translate(Vector2d) // Move Obj2D by magnitude provided by vector passed Scale(float64) // Scale X,Y of all Points by Z magnitude ScaleX(float64) // Scale X of all Points by Z magnitude ScaleY(float64) // Scale Y of all Points by Z magnitude ScaleXY(float64, float64) // Scale X and Y of all points by Z and A respectively RotateAbout(Vector2d, float64) // Rotate all points around given point by X degrees RotateAboutCenter(float64) // Rotate a 2D Object about its center }
Obj2D is an interface defining the API for any 2D object that can be handled by the renderer
type Obj3D ¶
type Obj3D interface { Obj2D ScaleXZ(float64, float64) // Scale X and Z values by A and B magnitudes ScaleYZ(float64, float64) // Scale Y and Z values by A and B magnitudes ScaleXYZ(float64, float64) // Scale X, Y, and Z values by A, B, and C magnitudes Scale3D(float64) // Scale all Values by some magnitude Translate3D(Vector3d) // Translate by a 3D value RotateAboutPoint3D(Vector3d, Vector3d) // Rotate about some point by some degrees X,Y,Z rads stored as a vector RotateAboutCenter3D(Vector3d) // Rotate a 3D object About its center }
Obj3D is an interface defining the API for any 3D object that can be handled by the renderer
type Quad ¶
type Quad struct { /* Quad line mappings 1->2 1->3 2->4 3->4 */ Point1 Vector2d `json:"Point1"` // Top Left Point2 Vector2d `json:"Point2"` // Top Right Point3 Vector2d `json:"Point3"` // Bottom Left Point4 Vector2d `json:"Point4"` // Bottom Right }
Quad is a 4 point Polygon
func (*Quad) GetTriangles ¶
func (*Quad) RotateAbout ¶
RotateAbout rotates the entire poly about an arbitrary point
func (*Quad) RotateAboutCenter ¶
RotateAboutCenter rotates about the center of the quad
type Renderable ¶
type RenderableComposite ¶
type RenderableComposite interface { GetTriangles() []Triangle RenderComposite() ([][]Vector2d, error) }
RenderableComposite constructs an Obj2D image as a more complicated shape
type Triangle ¶
type Triangle struct { Point1 Vector2d `json:"Point1"` // Point 1 of the Triangle Point2 Vector2d `json:"Point2"` // Point 2 of the Triangle Point3 Vector2d `json:"Point3"` // Point 3 of the Triangle Centroid Vector2d `json:"Centroid"` // The Centroid of the Triangle }
Triangle is a type describing a Triangle on a 2D plane
func MakeTriangle ¶
MakeTriangle creates a triangle struct populated with all the appropriate stuff
func (*Triangle) RotateAbout ¶
RotateAbout rotates a triangle about a given point
func (*Triangle) RotateAboutCenter ¶
RotateAboutCenter rotates a triangle about the center of itself
type Vector2d ¶
Vector2d is a 2d Vector storing doubles
func DrawCurve ¶
DrawCurve returns a slice containing points on a given types.curve, Bezier curves take control points as arguments, the only time that All points given are guaranteed to exist on a line is when there's Only two points provided. this outputs it in whatever scale you provided the input in If the coords are in world space, it returns world space If they're screen space, it returns screen space, if it's pixels, it returns pixels etc. etc.
func GetCompositeVector2dMinMax ¶
GetCompositeVector2dMinMax does the same but for 2d arrays
func GetVector2dMinMax ¶
GetVector2dMinMax returns the minimum and maximum X,Y values shared across a group of vectors
func (*Vector2d) GetDotProduct ¶
GetDotProduct gets the Dot Product of two vectors
func (*Vector2d) GetRelativeCoords ¶
GetRelativeCoords gets the relative coordinates of a point from another given point
func (*Vector2d) RotateAbout ¶
RotateAbout rotates a point around an arbitrary point by some amount of radians
func (*Vector2d) RotateAboutCenter ¶
RotateAboutCenter does nothing on a 2D vector
func (*Vector2d) Scale ¶
Scale does what you think it does. it also deliberately allows for negative values so you can invert it this way :)
type Vector3d ¶
Vector3d is the primitive type for all 3D objects
func (*Vector3d) GetRelativeCoords3D ¶
GetRelativeCoords3D gets the relative coordinates to some point in 3d space
func (*Vector3d) RotateAbout3D ¶
RotateAbout3D rotates the vector about some point on the X, Y, and Z axes (in that order) values in the amounts vector should be angles in radians
func (*Vector3d) RotateAboutCenter3D ¶
RotateAboutCenter3D does nothing on this as it's the center of itself
func (*Vector3d) RotateAboutX ¶
RotateAboutX rotates the vector about X by some rads
func (*Vector3d) RotateAboutY ¶
RotateAboutY rotates about Y by some rads
func (*Vector3d) RotateAboutZ ¶
RotateAboutZ rotates about the Z axis by some amount
func (*Vector3d) Translate3D ¶
Translate3D moves the vector by some point