[−][src]Struct polys::tri::Tri
Struct that represents a triangle.
Fields
side1: f64
side2: f64
side3: f64
Implementations
impl Tri
[src]
pub fn new(s1: f64, s2: f64, s3: f64) -> Tri
[src]
Returns a new Tri from given sides s1, s2, s3.
Examples
let tri = polys::Tri::new(24.0, 30.0, 18.0);
Trait Implementations
impl Debug for Tri
[src]
impl Polygon for Tri
[src]
fn area(&self) -> Option<f64>
[src]
Gets the area of the Tri from its sides.
Examples
use crate::polys::Polygon; let tri = polys::Tri::new(24.0, 30.0, 18.0); let area = tri.area().expect("Is none"); assert_eq!(area, 216.0);
fn peri(&self) -> Option<f64>
[src]
Gets the perimeter of the Tri from its sides.
Examples
use crate::polys::Polygon; let tri = polys::Tri::new(24.0, 30.0, 18.0); let peri = tri.peri().expect("Is none"); assert_eq!(peri, 72.0);
fn angles(&self) -> Option<Vec<f64>>
[src]
Returns the a vector of three angles in radians such that angles[0]
is the angle opposite side1
, angles[1]
is the angle opposite side2
, and angles[2]
is the angle opposite side3
.
Examples
use crate::polys::Polygon; use std::f64::consts::PI; let tri = polys::Tri::new(24.0, 30.0, 24.0); let ang = tri.angles().expect("Is none"); assert_eq!(ang[0]+ang[1]+ang[2], PI); assert_eq!(ang[0], ang[2]); //iso tri let tri = polys::Tri::new(12.0, 19.0, 8.0); let ang = tri.angles().expect("Is none"); assert_eq!(ang[0]+ang[1]+ang[2], PI); let tri = polys::Tri::new(12.0, 12.0, 12.0); let ang = tri.angles().expect("Is none"); assert_eq!((ang[0]+ang[1]+ang[2]) as f32, PI as f32);
Auto Trait Implementations
impl RefUnwindSafe for Tri
impl Send for Tri
impl Sync for Tri
impl Unpin for Tri
impl UnwindSafe for Tri
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,