Program Listing for File point.hxx

Return to documentation for file (src/acme/point.hxx)

/*
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                     *
 * The ACME project                                                    *
 *                                                                     *
 * Copyright (c) 2020, Davide Stocco and Enrico Bertolazzi.            *
 *                                                                     *
 * The ACME project and its components are supplied under the terms of *
 * the open source BSD 2-Clause License. The contents of the ACME      *
 * project and its components may not be copied or disclosed except in *
 * accordance with the terms of the BSD 2-Clause License.              *
 *                                                                     *
 * URL: https://opensource.org/licenses/BSD-2-Clause                   *
 *                                                                     *
 *    Davide Stocco                                                    *
 *    Department of Industrial Engineering                             *
 *    University of Trento                                             *
 *    e-mail: davide.stocco@unitn.it                                   *
 *                                                                     *
 *    Enrico Bertolazzi                                                *
 *    Department of Industrial Engineering                             *
 *    University of Trento                                             *
 *    e-mail: enrico.bertolazzi@unitn.it                               *
 *                                                                     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/


#pragma once
#ifndef INCLUDE_ACME_POINT_HXX
#define INCLUDE_ACME_POINT_HXX

#include "entity.hxx"
#include "math.hxx"

namespace acme
{

  /*\
   |               _       _
   |   _ __   ___ (_)_ __ | |_
   |  | '_ \ / _ \| | '_ \| __|
   |  | |_) | (_) | | | | | |_
   |  | .__/ \___/|_|_| |_|\__|
   |  |_|
  \*/


  class point : public vec3, public entity
  {
  public:
    using vec3::Matrix;

    point(point const &) = default;

    point(point &&) = default;

    point & operator=(const point &) = default;

    point & operator=(point &&) = default;

    ~point(void) override = default;

    point(void);

    template <typename derived>
    point(
      Eigen::MatrixBase<derived> const & other
    ) : vec3(other)
    {
    }

    void
    translate(
      vec3 const & vector_in
    ) override;

    void
    transform(
      affine const & affine_in
    ) override;

    bool
    isDegenerated(
      acme::real tolerance = EPSILON
    ) const override;

    inline
    integer
    level(void)
      const override
    {
      return integer(1);
    }

    inline
    std::string
    type(void)
      const override
    {
      return "point";
    }

    inline
    bool
    isNone(void)
      const override
    {
      return false;
    }

    inline
    bool
    isPoint(void)
      const override
    {
      return true;
    }

    inline
    bool
    isLine(void)
      const override
    {
      return false;
    }

    inline
    bool
    isRay(void)
      const override
    {
      return false;
    }

    inline
    bool
    isPlane(void)
      const override
    {
      return false;
    }

    inline
    bool
    isSegment(void)
      const override
    {
      return false;
    }

    inline
    bool
    isTriangle(void)
      const override
    {
      return false;
    }

    inline
    bool
    isDisk(void)
      const override
    {
      return false;
    }

    inline
    bool
    isBall(void)
      const override
    {
      return false;
    }

    inline
    bool
    isClampable(void)
      const override
    {
      return true;
    }

    inline
    bool
    isNonClampable(void)
      const override
    {
      return false;
    }

    bool
    clamp(
      vec3 & min,
      vec3 & max
    ) const override;

    bool
    clamp(
      acme::real & min_x,
      acme::real & min_y,
      acme::real & min_z,
      acme::real & max_x,
      acme::real & max_y,
      acme::real & max_z
    ) const override;

  }; // class point

  static point const & NAN_POINT   = * new point(QUIET_NAN, QUIET_NAN, QUIET_NAN);
  static point       & DUMMY_POINT = * new point(QUIET_NAN, QUIET_NAN, QUIET_NAN);

} // namespace acme

#endif