Show / Hide Table of Contents

Class PolarCoordinate

A Polar Coordinate.

Inheritance
Object
PolarCoordinate
Implements
IEquatable<PolarCoordinate>
IMatchable<PolarCoordinate>
IEquatable<(, )<Double, Double>>
IMatchable<(, )<Double, Double>>
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class PolarCoordinate : ValueType, IEquatable<PolarCoordinate>, IMatchable<PolarCoordinate>, IEquatable<(double, double)>, IMatchable<(double, double)>
Remarks

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

Constructors

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 Coord

Double theta

Degree of rotation (clockwise) of the Polar Coord

Fields

Radius

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

Declaration
public readonly double Radius
Field Value
Type Description
Double

Theta

The angle of rotation, clockwise, in radians

Declaration
public readonly double Theta
Field Value
Type Description
Double

Properties

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

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

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
Boolean

Whether these two PolarCoordinates are equal

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
Boolean

Whether or not these objects are equal

Equals((Double, Double))

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

Declaration
public bool Equals((double, double) other)
Parameters
Type Name Description
(, )<Double, Double> other
Returns
Type Description
Boolean

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

FromCartesian(Int32, Int32)

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
Int32 cartesianX

X-value of the cartesian point to analyze.

Int32 cartesianY

Y-value of the cartesian point to analyze.

Returns
Type Description
PolarCoordinate

An Equivalent Polar Coordinate

GetHashCode()

Gets the Object's Hash Code

Declaration
public override int GetHashCode()
Returns
Type Description
Int32

A Hash code.

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
Boolean

Whether these two PolarCoordinates are equal

Matches((Double, Double))

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

Declaration
public bool Matches((double, double) other)
Parameters
Type Name Description
(, )<Double, Double> other
Returns
Type Description
Boolean

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 Coord

ToString()

Ovverride ToString to help you debug

Declaration
public override string ToString()
Returns
Type Description
String

A short representation of the Polar Coordinate

Operators

Equality(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
Boolean

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

Equality(PolarCoordinate, (Double, Double))

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

Declaration
public static bool operator ==(PolarCoordinate c, (double, double) tuple)
Parameters
Type Name Description
PolarCoordinate c
(, )<Double, Double> tuple
Returns
Type Description
Boolean

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

Equality((Double, Double), PolarCoordinate)

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

Declaration
public static bool operator ==((double, double) tuple, PolarCoordinate c)
Parameters
Type Name Description
(, )<Double, Double> tuple
PolarCoordinate c
Returns
Type Description
Boolean

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

Implicit(PolarCoordinate to Point)

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.

Implicit(PolarCoordinate to (Double, Double))

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

Declaration
public static implicit operator (double, double)(PolarCoordinate c)
Parameters
Type Name Description
PolarCoordinate c
Returns
Type Description
(, )<Double, Double>

Implicit((Double, Double) to PolarCoordinate)

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

Declaration
public static implicit operator PolarCoordinate((double, double) tuple)
Parameters
Type Name Description
(, )<Double, Double> tuple
Returns
Type Description
PolarCoordinate

Inequality(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
Boolean

Whether these polar coordinates are dissimilar enough to not be equal

Inequality(PolarCoordinate, (Double, Double))

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

Declaration
public static bool operator !=(PolarCoordinate c, (double, double) tuple)
Parameters
Type Name Description
PolarCoordinate c
(, )<Double, Double> tuple
Returns
Type Description
Boolean

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

Inequality((Double, Double), PolarCoordinate)

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

Declaration
public static bool operator !=((double, double) tuple, PolarCoordinate c)
Parameters
Type Name Description
(, )<Double, Double> tuple
PolarCoordinate c
Returns
Type Description
Boolean

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

Implements

System.IEquatable<T>
IMatchable<T>
System.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>>)
In This Article
Back to top Generated by DocFX