tomato 1.2.4 Reference Manual

::tomato::mathray3dTop, Main, Index

A Class representing a Ray in 3D space

ClassesTop, Main, Index

Ray3d [::tomato::mathray3d]Top, Main, Index

Method summary
constructorConstructor for the class.
!=Gets value that indicates whether any pair of elements in two specified rays is not equal.
==Gets value that indicates whether each pair of elements in two specified rays is equal.
DirectionGets the direction mathvec3d::Vector3d of the ray
GetGets the start point and direction of the ray in the form of a Tcl list
GetTypeGets the name of class.
IsCollinearReturns a value to indicate if a pair of rays are collinear
ShortestLineTothe shortest line from a point to the ray
ThroughPointGets the start point mathpt3d::Point3d of the ray
ToStringReturns a string representation of this object.

constructor [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Initializes a new Ray3d Class.

Ray3d create OBJNAME point direction
Ray3d new point direction
Parameters
pointmathpt3d::Point3d
directionmathvec3d::Vector3d.
method constructor {point direction} {

    # Initializes a new Ray3d Class.
    #
    # point     - [mathpt3d::Point3d]
    # direction - [mathvec3d::Vector3d].
    #

    if {[tomato::helper::TypeOf $point Isa "Point3d"]} {
        set _throughpoint $point
    } else {
        error "Must be 'Point3d' ClassType"
    }

    if {[tomato::helper::TypeOf $direction Isa "Vector3d"]} {
        set _direction [$direction Normalized]
    } else {
        error "Must be 'Vector3d' ClassType"
    }
}

!= [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Gets value that indicates whether any pair of elements in two specified rays is not equal.

RAY3DOBJ != other ?tolerance?
Parameters
otherThe second ray Ray3d to compare.
toleranceA tolerance (epsilon) to adjust for floating point error. Optional, default $::tomato::helper::TolEquals.
Return value

Returns True if the rays are different. Otherwise False.

method != {other {tolerance {$::tomato::helper::TolEquals}}} {

    # Gets value that indicates whether any pair of elements in two specified rays is not equal.
    #
    # other - The second ray [Ray3d] to compare.
    # tolerance - A tolerance (epsilon) to adjust for floating point error.
    #
    # Returns `True` if the rays are different. Otherwise `False`.
    if {[llength [info level 0]] < 4} {
        set tolerance $::tomato::helper::TolEquals
    }

    return [expr {![tomato::mathray3d::Equals [self] $other $tolerance]}]
}

== [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Gets value that indicates whether each pair of elements in two specified rays is equal.

RAY3DOBJ == other ?tolerance?
Parameters
otherThe second ray Ray3d to compare.
toleranceA tolerance (epsilon) to adjust for floating point error. Optional, default $::tomato::helper::TolEquals.
Return value

Returns True if the rays are the same. Otherwise False.

method == {other {tolerance {$::tomato::helper::TolEquals}}} {

    # Gets value that indicates whether each pair of elements in two specified rays is equal.
    #
    # other     - The second ray [Ray3d] to compare.
    # tolerance - A tolerance (epsilon) to adjust for floating point error.
    #
    # Returns `True` if the rays are the same. Otherwise `False`.
    if {[llength [info level 0]] < 4} {
        set tolerance $::tomato::helper::TolEquals
    }

    return [expr {[tomato::mathray3d::Equals [self] $other $tolerance]}]
}

Direction [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Gets the direction mathvec3d::Vector3d of the ray

RAY3DOBJ Direction
method Direction {} {

    # Gets the direction [mathvec3d::Vector3d] of the ray
    return $_direction
}

Get [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Gets the start point and direction of the ray in the form of a Tcl list

RAY3DOBJ Get
method Get {} {

    # Gets the start point and direction of the ray in the form of a Tcl list
    return [list $_throughpoint $_direction]
}

GetType [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Gets the name of class.

RAY3DOBJ GetType
method GetType {} {

    # Gets the name of class.
    return [tomato::helper::TypeClass [self]]
}

IsCollinear [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Returns a value to indicate if a pair of rays are collinear

RAY3DOBJ IsCollinear other ?tolerance?
Parameters
otherThe ray to compare against Ray3d
toleranceA tolerance (epsilon) for plane parallel verification. Optional, default $::tomato::helper::TolGeom.
Return value

Returns a value to indicate if a pair of rays are collinear

method IsCollinear {other {tolerance {$::tomato::helper::TolGeom}}} {

    # Returns a value to indicate if a pair of rays are collinear
    #
    # other - The ray to compare against [Ray3d]
    # tolerance - A tolerance (epsilon) for plane parallel verification.
    if {[llength [info level 0]] < 4} {
        set tolerance $::tomato::helper::TolGeom
    }

    return [[my Direction] IsParallelTo [$other Direction] $tolerance]
}

ShortestLineTo [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

the shortest line from a point to the ray

RAY3DOBJ ShortestLineTo point3d
Parameters
point3dA point mathpt3d::Point3d
Return value

Returns a new line mathline3d::Line3d from the point to the closest point on the ray

method ShortestLineTo {point3d} {

    # the shortest line from a point to the ray
    #
    # point3d - A point [mathpt3d::Point3d]
    #
    # Returns a new line [mathline3d::Line3d] from the point to the closest point on the ray
    set v [[my ThroughPoint] VectorTo $point3d]
    set alongVector [$v ProjectOn [my Direction]]

    return [tomato::mathline3d::Line3d new [[my ThroughPoint] + $alongVector] $point3d]
}

ThroughPoint [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Gets the start point mathpt3d::Point3d of the ray

RAY3DOBJ ThroughPoint
method ThroughPoint {} {

    # Gets the start point [mathpt3d::Point3d] of the ray
    return $_throughpoint
}

ToString [::tomato::mathray3d::Ray3d]Ray3d, Top, Main, Index

Returns a string representation of this object.

RAY3DOBJ ToString
Return value

Returns a string representation of this object.

method ToString {} {

    # Returns a string representation of this object.
    lappend value "ThroughPoint = [$_throughpoint ToString]"
    lappend value "Direction    = [$_direction ToString]"

    return [join $value "\n"]
}

CommandsTop, Main, Index

Equals [::tomato::mathray3d]Top, Main, Index

Indicate if this ray is equivalent to a given ray

Equals ray other tolerance
Parameters
rayFirst input ray Ray3d
otherSecond input ray Ray3d
toleranceA tolerance (epsilon) to adjust for floating point error
Description

See : methods == !=

An error exception is raised if tolerance (epsilon) < 0.

Return value

Returns True if the rays are equal, otherwise false.

proc ::tomato::mathray3d::Equals {ray other tolerance} {

    # Indicate if this ray is equivalent to a given ray
    #
    # ray - First input ray [Ray3d]
    # other - Second input ray [Ray3d]
    # tolerance - A tolerance (epsilon) to adjust for floating point error
    #
    # Returns `True` if the rays are equal, otherwise false.
    #
    # See : methods == !=
    if {$tolerance < 0} {
        #ruff
        # An error exception is raised if tolerance (epsilon) < 0.
        error "epsilon < 0"
    }

    return [expr {
                  [tomato::mathpt3d::Equals  [$ray ThroughPoint] [$other ThroughPoint] $tolerance] &&
                  [tomato::mathvec3d::Equals [$ray Direction] [$other Direction] $tolerance]
                }]
}

IntersectionPlaneWithPlane [::tomato::mathray3d]Top, Main, Index

Gets the intersection of the two planes.

IntersectionPlaneWithPlane plane1 plane2 ?tolerance?
Parameters
plane1The first plane mathplane::Plane
plane2The second plane mathplane::Plane
toleranceA tolerance (epsilon) for plane parallel verification. Optional, default $::tomato::helper::TolGeom.
Return value

Returns a ray Ray3d at the intersection of two planes.

proc ::tomato::mathray3d::IntersectionPlaneWithPlane {plane1 plane2 {tolerance {$::tomato::helper::TolGeom}}} {

    # Gets the intersection of the two planes.
    #
    # plane1 - The first plane  [mathplane::Plane]
    # plane2 - The second plane [mathplane::Plane]
    # tolerance - A tolerance (epsilon) for plane parallel verification.
    #
    # Returns a ray [Ray3d] at the intersection of two planes.
    if {[llength [info level 0]] < 4} {
        set tolerance $::tomato::helper::TolGeom
    }

    return [$plane1 IntersectionWith $plane2 $tolerance]
}

IntersectionRayWithPlane [::tomato::mathray3d]Top, Main, Index

Gets the intersection of ray and plane.

IntersectionRayWithPlane ray plane ?tolerance?
Parameters
rayRay3d
planemathplane::Plane
toleranceA tolerance (epsilon) for ray parallel with plane verification. Optional, default $::tomato::helper::TolGeom.
Return value

Returns a point mathpt3d::Point3d at the intersection with plane.

proc ::tomato::mathray3d::IntersectionRayWithPlane {ray plane {tolerance {$::tomato::helper::TolGeom}}} {

    # Gets the intersection of ray and plane.
    #
    # ray       - [Ray3d]
    # plane     - [mathplane::Plane]
    # tolerance - A tolerance (epsilon) for ray parallel with plane verification.
    #
    # Returns a point [mathpt3d::Point3d] at the intersection with plane.
    if {[llength [info level 0]] < 4} {
        set tolerance $::tomato::helper::TolGeom
    }

    return [$plane IntersectionWith $ray $tolerance]
}