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 bvh::{
aabb::{Bounded, AABB},
@ -8,6 +10,7 @@ use serde::Deserialize;
/// All the existing `Shape` implementation.
#[serde(tag = "type")]
#[serde(rename_all = "lowercase")]
#[allow(missing_docs)]
#[enum_dispatch::enum_dispatch]
#[derive(Debug, PartialEq, Deserialize)]
pub enum ShapeEnum {

View File

@ -13,6 +13,22 @@ pub struct 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 {
Triangle {
c0,