00001 /* 00002 toxic - A Global Illumination Renderer 00003 Copyright (C) 2003-2004 Francois Beaune 00004 Contact: http://toxicengine.sourceforge.net/ 00005 00006 This file is part of toxic. 00007 00008 toxic is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 toxic is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with toxic; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 //! Vector v is expressed in local space, returned vector is expressed in world space. 00024 inline 00025 sheep::Vector3 Basis::TransformToWorld(const sheep::Vector3 &v) const { 00026 return m_m * v; 00027 } 00028 00029 //! Point p is expressed in local space, returned point is expressed in world space. 00030 inline 00031 sheep::Point3 Basis::TransformToWorld(const sheep::Point3 &v) const { 00032 return m_m * v; 00033 } 00034 00035 //! Vector v is expressed in world space, returned vector is expressed in local space. 00036 inline 00037 sheep::Vector3 Basis::TransformToLocal(const sheep::Vector3 &v) const { 00038 return m_inv_m * v; 00039 } 00040 00041 //! Point p is expressed in world space, returned point is expressed in local space. 00042 inline 00043 sheep::Point3 Basis::TransformToLocal(const sheep::Point3 &v) const { 00044 return m_inv_m * v; 00045 } 00046 00047 //! Ray r is expressed in local space, returned ray is expressed in world space. 00048 //! Direction vector of the returned ray MAY NOT be unit-length. 00049 inline 00050 Ray Basis::TransformToWorld(const Ray &r) const { 00051 return Ray(r.GetType(), m_m * r.m_origin, m_m * r.m_direction); 00052 } 00053 00054 //! Ray r is expressed in world space, returned ray is expressed in local space. 00055 //! Direction vector of the returned ray MAY NOT be unit-length. 00056 inline 00057 Ray Basis::TransformToLocal(const Ray &r) const { 00058 return Ray(r.GetType(), m_inv_m * r.m_origin, m_inv_m * r.m_direction); 00059 } 00060 00061 //! Normal n is expressed in local space, returned normal is expressed in world space. 00062 //! The returned vector IS unit-length. 00063 inline 00064 sheep::Vector3 Basis::TransformNormalToWorld(const sheep::Vector3 &n) const { 00065 return (m_tr_inv_m * n).Normalized(); 00066 } 00067 00068 //! Normal n is expressed in world space, returned normal is expressed in local space. 00069 //! The returned vector IS unit-length. 00070 inline 00071 sheep::Vector3 Basis::TransformNormalToLocal(const sheep::Vector3 &n) const { 00072 return (m_tr_m * n).Normalized(); 00073 }
1.3.6