Karan Soni
Karan Soni

Reputation: 1

Can someone pleaase clarify the meaning of the entire code mentioned below?

$seg addPoint "[expr -0.5 * $l] $r 0"

I have to convert above TCL code to python code for meshing, but I am unable to understand the above code.Can someone explain me the eqaution in the code?

Upvotes: 0

Views: 58

Answers (1)

Chris Heithoff
Chris Heithoff

Reputation: 1863

The first word $seg is likely an object that was created, possibly using Tcl::oo as the object-oriented framework. This is probably a line segment consisting of two points.

addPoint looks like a method to add a point to the segment.

"[expr -0.5*$l] $r 0" is a three-item list used as an argument to the method. Why is it three items?

expr is the Tcl command to do math operations, so expr -0.5 * $l is just multiplying -0.5 by the value of $l.

A possible Python equivalent would be:

seg = Segment()
l = 2.0
r = 1.0
seg.addPoint(-0.5 * l, r, 0)

...where creating the Segment class and addPoint() method is up to you.

Upvotes: 2

Related Questions