[vtkusers] Re: vtkmath in tcl

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu Jul 21 08:55:33 EDT 2005


Hi Alberto,

The only vectors operations in vtkMath that work in tcl are vtkMath::Norm 
and vtkMath::Norm2D

It would be easy enough to extend vtkMath to wrap Cross and Dot into tcl... 
you might like to add it as an idea to the bug tracker - 
http://www.vtk.org/Bug

Here are some tcl procs I use to do Dot and Cross

proc DotProd {a b} {

    if {[llength $a] < 3 || [llength $b] < 3} {
        return -code error "Vectors must have 3 components!"
    }

    scan $a "%f %f %f" ax ay az
    scan $b "%f %f %f" bx by bz

    return [expr {$ax*$bx + $ay*$by + $az*$bz}]

}

proc CrossProd {a b} {

    if {[llength $a] < 3 || [llength $b] < 3} {
        return -code error "Vectors must have 3 components!"
    }

    scan $a "%f %f %f" ax ay az
    scan $b "%f %f %f" bx by bz

    set cx [expr {$ay*$bz - $az*$by}]
    set cy [expr {$az*$bx - $ax*$bz}]
    set cz [expr {$ax*$by - $ay*$bx}]

    return [list $cx $cy $cz]
}

use them like this: CrossProd {1 2 3} {4 5 6}


hth

Goodwin


"Alberto Magrofuoco" <abemagro at yahoo.it> wrote in message 
news:20050721091455.32654.qmail at web31409.mail.mud.yahoo.com...
Can I use vtkmath's Cross,Dot and the other vector operations in a tcl 
script,how can i pass the arguments? Where  can I find some examples?
All the examples i' ve seen in tcl used vtkmath only for the function 
random.


Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3



_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: 
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers 






More information about the vtkusers mailing list