Show / Hide Table of Contents

Struct PolarCoordinate

A Polar Coordinate.

Implements
IEquatable<PolarCoordinate>
IMatchable<PolarCoordinate>
IEquatable<(double radius, double theta)>
IMatchable<(double radius, double theta)>
Inherited Members
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
[DataContract]
public readonly struct PolarCoordinate : IEquatable<PolarCoordinate>, IMatchable<PolarCoordinate>, IEquatable<(double radius, double theta)>, IMatchable<(double radius, double theta)>
Remarks

See wikipedia: https://en.wikipedia.org/wiki/Polar_coordinate_system Polar Coordinates are very, very slow and should not be used often

Constructors

View Source

PolarCoordinate(double, double)

Creates a new Polar Coordinate with the given Radius and Theta

Declaration
public PolarCoordinate(double radius, double theta)
Parameters
Type Name Description
double radius

Radius of the Polar Coordinate

double theta

Degree of rotation (clockwise) of the Polar Coordinate

Fields

View Source

Radius

The distance away from the Origin (0,0) of this Polar Coordinate

Declaration
[DataMember]
public readonly double Radius
Field Value
Type Description
double
View Source

Theta

The angle of rotation, clockwise, in radians

Declaration
[DataMember]
public readonly double Theta
Field Value
Type Description
double

Properties

View Source

Functions

A handy list of example polar functions for you.

Declaration
public static Dictionary<string, Func<double, Point>> Functions { get; }
Property Value
Type Description
Dictionary<string, Func<double, Point>>
Remarks

This list contains several examples of Polar Coordinates you can use. Add more by calling PolarFunctions.Add((theta) => { Return new PolarCoordinate(radius, theta);});

Each function accepts a parameter of Theta, which is the angle of rotation around the center. They return a Point that can be used on the map. Polar functions are very slow. Use them seldom, for things like spirographs As the radius gets larger, there will be increased likelihood of functions producing gaps in output. You've been warned.

Methods

View Source

Deconstruct(out double, out double)

Adds support for C# Deconstruction syntax.

Declaration
public void Deconstruct(out double radius, out double theta)
Parameters
Type Name Description
double radius
double theta
View Source

Equals(PolarCoordinate)

Performs comparison between this PolarCoordinate and an other

Declaration
public bool Equals(PolarCoordinate other)
Parameters
Type Name Description
PolarCoordinate other

The other Polar Coordinate to analyze

Returns
Type Description
bool

Whether these two PolarCoordinates are equal

View Source

Equals(object?)

Compares the equality of this Polar Coordinate to another object

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object against which to compare

Returns
Type Description
bool

Whether or not these objects are equal

Overrides
ValueType.Equals(object)
View Source

Equals((double radius, double theta))

Compares the values in this polar coordinate to the specified values.

Declaration
public bool Equals((double radius, double theta) other)
Parameters
Type Name Description
(double radius, double theta) other
Returns
Type Description
bool
View Source

FromCartesian(Point)

Returns a new PolarCoordinate that is equivalent to the Cartesian point provided.

Declaration
public static PolarCoordinate FromCartesian(Point cartesian)
Parameters
Type Name Description
Point cartesian

The cartesian point to analyze

Returns
Type Description
PolarCoordinate

An Equivalent Polar Coordinate

View Source

FromCartesian(int, int)

Returns a new PolarCoordinate that is equivalent to the Cartesian point provided.

Declaration
public static PolarCoordinate FromCartesian(int cartesianX, int cartesianY)
Parameters
Type Name Description
int cartesianX

X-value of the cartesian point to analyze.

int cartesianY

Y-value of the cartesian point to analyze.

Returns
Type Description
PolarCoordinate

An Equivalent Polar Coordinate

View Source

GetHashCode()

Gets the Object's Hash Code

Declaration
public override int GetHashCode()
Returns
Type Description
int

A Hash code.

Overrides
ValueType.GetHashCode()
View Source

Matches(PolarCoordinate)

Performs comparison between this PolarCoordinate and an other

Declaration
public bool Matches(PolarCoordinate other)
Parameters
Type Name Description
PolarCoordinate other

The other Polar Coordinate to analyze

Returns
Type Description
bool

Whether these two PolarCoordinates are equal

View Source

Matches((double radius, double theta))

Compares the values in this polar coordinate to the specified values.

Declaration
public bool Matches((double radius, double theta) other)
Parameters
Type Name Description
(double radius, double theta) other
Returns
Type Description
bool
View Source

ToCartesian()

Returns the Cartesian Equivalent of this Polar Coordinate

Declaration
public Point ToCartesian()
Returns
Type Description
Point

A Cartesian Coordinate that points at the same spot on the map as the Polar Coordinate

View Source

ToString()

Override ToString to help you debug

Declaration
public override string ToString()
Returns
Type Description
string

A short representation of the Polar Coordinate

Overrides
ValueType.ToString()

Operators

View Source

operator ==(PolarCoordinate, PolarCoordinate)

Compares two polar Coordinates

Declaration
public static bool operator ==(PolarCoordinate left, PolarCoordinate right)
Parameters
Type Name Description
PolarCoordinate left

The first polar coordinate to analyze

PolarCoordinate right

The Second polar coordinate to analyze

Returns
Type Description
bool

Whether or not these two Polar Coordinates are similar enough to be considered "Equal"

View Source

operator ==(PolarCoordinate, (double radius, double theta))

True if the two polar coordinates' radius and theta values are close enough to equal.

Declaration
public static bool operator ==(PolarCoordinate c, (double radius, double theta) tuple)
Parameters
Type Name Description
PolarCoordinate c
(double radius, double theta) tuple
Returns
Type Description
bool

True if the two polar coordinates are equivalent, false if not.

View Source

operator ==((double radius, double theta), PolarCoordinate)

True if the two polar coordinate's values are equivalent.

Declaration
public static bool operator ==((double radius, double theta) tuple, PolarCoordinate c)
Parameters
Type Name Description
(double radius, double theta) tuple
PolarCoordinate c
Returns
Type Description
bool

True if the two polar coordinates are equal, false if not.

View Source

implicit operator Point(PolarCoordinate)

Implicitly converts the polar coordinate to its cartesian plane equivalent.

Declaration
public static implicit operator Point(PolarCoordinate pos)
Parameters
Type Name Description
PolarCoordinate pos

Polar coordinate to convert.

Returns
Type Description
Point

The equivalent cartesian coordinate.

View Source

implicit operator (double radius, double theta)(PolarCoordinate)

Implicitly converts a PolarCoordinate to an equivalent tuple of two doubles.

Declaration
public static implicit operator (double radius, double theta)(PolarCoordinate c)
Parameters
Type Name Description
PolarCoordinate c
Returns
Type Description
(double radius, double theta)
View Source

implicit operator PolarCoordinate((double radius, double theta))

Implicitly converts a tuple of two doubles to an equivalent PolarCoordinate.

Declaration
public static implicit operator PolarCoordinate((double radius, double theta) tuple)
Parameters
Type Name Description
(double radius, double theta) tuple
Returns
Type Description
PolarCoordinate
View Source

operator !=(PolarCoordinate, PolarCoordinate)

Compares two PolarCoordinates

Declaration
public static bool operator !=(PolarCoordinate left, PolarCoordinate right)
Parameters
Type Name Description
PolarCoordinate left

The first polar coordinate to analyze

PolarCoordinate right

The second PolarCoordinate to analyze

Returns
Type Description
bool

Whether these polar coordinates are dissimilar enough to not be equal

View Source

operator !=(PolarCoordinate, (double radius, double theta))

True if either the radius or theta values aren't equivalent.

Declaration
public static bool operator !=(PolarCoordinate c, (double radius, double theta) tuple)
Parameters
Type Name Description
PolarCoordinate c
(double radius, double theta) tuple
Returns
Type Description
bool

True if either the radius or theta values are not equal, false if they are both equal.

View Source

operator !=((double radius, double theta), PolarCoordinate)

True if either the radius or theta values are not equal.

Declaration
public static bool operator !=((double radius, double theta) tuple, PolarCoordinate c)
Parameters
Type Name Description
(double radius, double theta) tuple
PolarCoordinate c
Returns
Type Description
bool

True if either the radius or theta values are not equal, false if they are both equal.

Implements

IEquatable<T>
IMatchable<T>
IEquatable<T>
IMatchable<T>

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>?)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>?, EventHandler<ValueChangedEventArgs<TProperty>>?)
  • View Source
In this article
Back to top Generated by DocFX