Struct Angle
- Namespace
- CADability
- Assembly
- CADability.dll
An angle defined in radians. The value of the angle is a double which is greater or equal to 0 and less than (and not equal) 2*pi. Via cast operators the angle seamlessly operates as a double.
public struct Angle : ISerializable
- Implements
- Inherited Members
Constructors
Angle(GeoPoint2D, GeoPoint2D)
Constructs the angle
public Angle(GeoPoint2D Target, GeoPoint2D Center)
Parameters
TargetGeoPoint2DCenterGeoPoint2D
Angle(GeoVector, GeoVector)
Constructs the angle that is enclosed by the two vectors (between 0 and Math.PI)
public Angle(GeoVector v1, GeoVector v2)
Parameters
Angle(GeoVector2D)
Constructs the angle of the given vector. X-axis is 0, counterclockwise.
public Angle(GeoVector2D v)
Parameters
vGeoVector2Dvector to define the angle
Angle(GeoVector2D, GeoVector2D)
Constructs the angle that is needed to rotate the first vector counterclockwise to reach the second vector (between 0 and 2.0*Math.PI)
public Angle(GeoVector2D v1, GeoVector2D v2)
Parameters
v1GeoVector2DFirst vector
v2GeoVector2DSecond vector
Angle(double)
Constructs an angle from the provided parameter
public Angle(double d)
Parameters
ddoubleAngle in radians
Angle(double, double)
Constructs an angle of a 2d vector (dx,dy)
public Angle(double dx, double dy)
Parameters
Properties
A0
Angle for 0°
public static Angle A0 { get; }
Property Value
A180
Angle for 180°
public static Angle A180 { get; }
Property Value
A270
Angle for 270°
public static Angle A270 { get; }
Property Value
A30
Angle for 30°
public static Angle A30 { get; }
Property Value
A45
Angle for 45°
public static Angle A45 { get; }
Property Value
A60
Angle for 60°
public static Angle A60 { get; }
Property Value
A90
Angle for 90°
public static Angle A90 { get; }
Property Value
Degree
The value of this angle in degrees. A value that is set is converted to radians and reduced modulo 360°.
public double Degree { get; set; }
Property Value
- double
The angle in degrees.
Direction
Sets the angle to the angle of the given vector. Gets a unit vector with the angle.
public GeoVector2D Direction { get; set; }
Property Value
Quadrant
Quadrant of the angle. Yields 0 to 3. 0: right top, 1: left top, 2: left bottom, 3: right bottom
public int Quadrant { get; }
Property Value
Radian
The value of this angle in radians. A value that is set is reduced modulo 2*pi.
public double Radian { get; set; }
Property Value
- double
The angle in radians.
Methods
Deg(double)
Creates an angle from the provided parameter (in degrees)
public static Angle Deg(double deg)
Parameters
degdoubleDegrees of the angle
Returns
- Angle
The resulting angle
FromDegree(double)
Returns an angle from the parameter interpreted as degrees
public static Angle FromDegree(double d)
Parameters
ddoubleDegrees of the angle
Returns
- Angle
The angle
GetObjectData(SerializationInfo, StreamingContext)
Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
IsCloseTo(Angle, double)
Returns true if the radians differ less than 1e-6 or provided tolerance
public bool IsCloseTo(Angle ang, double tolerance = 1E-06)
Parameters
Returns
Sweeps(SweepAngle, Angle)
Determines whether the angle test lies within the range that is swept when starting
at this angle and turning by the sweep angle sa (counterclockwise for a positive,
clockwise for a negative sweep angle). The limits of the range count as inside.
public bool Sweeps(SweepAngle sa, Angle test)
Parameters
saSweepAnglethe sweep, starting at this angle
testAnglethe angle to test
Returns
- bool
true if
testis within the swept range
ToString()
Representation of this angle as a string in degrees
public override string ToString()
Returns
Operators
operator +(Angle, SweepAngle)
Adds the sweep angle to the angle
public static Angle operator +(Angle angA, SweepAngle angB)
Parameters
angAAngleFirst operand
angBSweepAngleSweep angle to add
Returns
- Angle
The sum
implicit operator double(Angle)
Casts an angle to a double. The radian of the angle is returned.
the anglepublic static implicit operator double(Angle ang)
Parameters
angAngle
Returns
implicit operator Angle(SweepAngle)
Casts the sweep angle to an angle with the same value
public static implicit operator Angle(SweepAngle sw)
Parameters
swSweepAngle
Returns
implicit operator Angle(double)
Casts a double to an angle. The result will be between 0 and 2*pi
double valuepublic static implicit operator Angle(double v)
Parameters
vdouble
Returns
operator -(Angle, Angle)
Returns the sweep angle that leads from angB to angA
public static SweepAngle operator -(Angle angA, Angle angB)
Parameters
Returns
- SweepAngle
The difference
operator -(Angle, SweepAngle)
Returns the angle minus the provided sweep angle
public static Angle operator -(Angle angA, SweepAngle angB)
Parameters
angAAnglefirst argument
angBSweepAnglesubtract this
Returns
- Angle
the difference