library: document shape module

This commit is contained in:
Antoine Martin 2020-03-22 00:42:37 +01:00
parent ce1b8eeaaa
commit a9fd726a0d
2 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,5 @@
//! Various shape implementations
use super::{Point, Point2D, Vector}; use super::{Point, Point2D, Vector};
use bvh::{ use bvh::{
aabb::{Bounded, AABB}, aabb::{Bounded, AABB},
@ -8,6 +10,7 @@ use serde::Deserialize;
/// All the existing `Shape` implementation. /// All the existing `Shape` implementation.
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
#[allow(missing_docs)]
#[enum_dispatch::enum_dispatch] #[enum_dispatch::enum_dispatch]
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
pub enum ShapeEnum { pub enum ShapeEnum {

View file

@ -13,6 +13,22 @@ pub struct Triangle {
} }
impl Triangle { impl Triangle {
/// Creates a new `Triangle` from 3 [`Point`]s.
///
/// [`Point`]: ../../type.Point.html
///
/// # Examples
///
/// ```
/// # use pathtracer::shape::Triangle;
/// # use pathtracer::Point;
/// #
/// let t = Triangle::new(
/// Point::new(1.0, 0.0, 0.0),
/// Point::new(0.0, 1.0, 0.0),
/// Point::new(0.0, 0.0, 1.0),
/// );
/// ```
pub fn new(c0: Point, c1: Point, c2: Point) -> Self { pub fn new(c0: Point, c1: Point, c2: Point) -> Self {
Triangle { Triangle {
c0, c0,