Sponsored Content
Top Forums Shell Programming and Scripting problem with floating point number loops Post 302430699 by ergy1983 on Friday 18th of June 2010 11:12:47 AM
Old 06-18-2010
problem with floating point number loops

Hey,

I guess I am just to stupid and am not seeing the "wood for the trees", but I am always getting strange errors.

I want to create a mesh with coordinates like:

x y z
3.1 3.0 0.75 0 0 1
3.1 2.9 0.75 0 0 1
3.1 2.8 0.75 0 0 1
3.1 2.7 0.75 0 0 1
3.0 3.0 0.75 0 0 1
3.0 2.9 0.75 0 0 1
3.0 2.8 0.75 0 0 1
3.0 2.7 0.75 0 0 1

Here is my skript:

Code:
echo "Abstand Berechnungspunkte in Meter="
read abstand

z=0.75
a=0
b=0
c=1

for (( i=$abstand; i<0; i=$i+$abstand )) 
do
			for (( h=$abstand; h<4.61; h=$h+$abstand )) 
			do
						x=`echo "-3.616+$i" |bc -l `
						y=`echo "-0.085+$h" |bc -l `
						print $x " " $y " " $z " " $a " " $b " " $c
			done
done

or I also tried this one:

Code:
echo "Abstand Berechnungspunkte in Meter="
read abstand 

    z=.75
    a=0
    b=0
    c=1
    ab=$abstand
    i=-3.616
    h=0
    maxx=0
    maxy=4.61
    
    while [ $i -le $maxx ]
    do 
            x=`echo "-3.616+$i" |bc -l`
            i=`echo "$i+$ab" |bc -l`
    done

But it is always creating the same problem regarding numbers with commata. Becasue my input is e.g., 0.02
line 11: ((: i=0.1: syntax error: invalid arithmetic operator (error token is ".1")

Does anyone has an idea? Thanks for any help and sorry for the stupid question,
Sam
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem with floating point numbers in awk

hi all, i have the following problem using awk in a script i want to read the values from a column with real numbers and calculate the mean.the problem is that when i use a statement such as this num = $4 i cant find a way to convert the variable from string to floating point to perform... (7 Replies)
Discussion started by: kanagias
7 Replies

2. Programming

floating point problem

Hi all! Hi all! I am working with a problem to find the smallest floating point number that can be represented. I am going in a loop ,stating with an initial value of 1.0 and then diving it by 10 each time thru the loop. So the first time I am getting o.1 which I wanted.But from the next... (4 Replies)
Discussion started by: vijlak
4 Replies

3. Shell Programming and Scripting

using bc with floating point number in files

Hi, I' using bash and I would like to use "bc" to compute the ratio of of two numbers and assign the ratio to a variable. The numbers are in a file, e.g. 196.304492 615.348986 Any idea how to do it? N.B. I cannot change the file to have 196.304492 / 615.348986 as the file is produced by... (14 Replies)
Discussion started by: f_o_555
14 Replies

4. Shell Programming and Scripting

floating point numbers in if

# if > then > echo "1" > else > echo "2" > fi -bash: How can i compare floating point numbers inside statement? (15 Replies)
Discussion started by: proactiveaditya
15 Replies

5. Shell Programming and Scripting

Arithmetic in floating point

is it not possible to simply di aritmetic without using bc or awk i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant... (6 Replies)
Discussion started by: sumit the cool
6 Replies

6. Shell Programming and Scripting

floating point number problem

Hello folks I Hope everyone is fine. I am calculating number of bytes calculation from apache web log. awk '{ sum += $10 } END { print sum }' /var/httpd/log/mydomain.log 7.45557e+09 it show above number, what should i do it sow number like 7455, i mean if after decimal point above 5 it... (5 Replies)
Discussion started by: learnbash
5 Replies

7. Programming

Floating Point

Anyone help me i cant found the error of floating point if needed, i added the code complete #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> typedef struct { int hh; int mm; int ss; char nom; int punt; }cancion; typedef struct... (9 Replies)
Discussion started by: Slasho
9 Replies

8. Shell Programming and Scripting

[BASH] Regex for floating point number

Hey again, I have a basic regex that tests if a number is a float. Thank you. (5 Replies)
Discussion started by: whyte_rhyno
5 Replies

9. Shell Programming and Scripting

Convert floating point to a number

Hello Guys, I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value #!/bin/bash #... (9 Replies)
Discussion started by: skatpally
9 Replies

10. Shell Programming and Scripting

Bash script to print the smallest floating point number in a row that is not 0

Hello, I have often found bash to be difficult when it comes to floating point numbers. I have data with rows of tab delimited floating point numbers. I need to find the smallest number in each row that is not 0.0. Numbers can be negative and they do not come in any particular order for a given... (9 Replies)
Discussion started by: LMHmedchem
9 Replies
OBJ2MESH(1)						      General Commands Manual						       OBJ2MESH(1)

NAME
obj2mesh - create a compiled RADIANCE mesh file from Wavefront .OBJ input SYNOPSIS
obj2mesh [ -a matfile ][ -l matlib ][ -n objlim ][ -r maxres ][ -w ] [ input.obj [ output.rtm ] ] DESCRIPTION
Obj2mesh reads a Wavefront .OBJ file from input.obj (or the standard input) and compiles it into a RADIANCE triangle mesh, which is sent to output.rtm (or standard output). Any RADIANCE material descriptions included via one or more -a options will be compiled and stored in the mesh as well. If the -l option is used to specify a material file, the RADIANCE library locations are searched. This mesh may be included in a RADIANCE scene description via the mesh primitive, thus: mod mesh id 1+ output.rtm [xform args] 0 0 The syntax and semantics are identical to the RADIANCE instance primitive. If mod is "void", then the stored mesh materials will be applied during rendering. Otherwise, the given material will be substituted on all the mesh surfaces. The -n option specifies the maximum surface set size for each voxel. Larger numbers result in quicker mesh generation, but potentially slower rendering. Values below 6 are not recommended, since this is the median valence for a mesh vertex (the number of adjacent faces), and smaller values will result in pointless octree subdivision. The default setting is 9. The -r option specifies the maximum octree resolution. This should be greater than or equal to the ratio of the mesh bounding box to the smallest triangle. The default is 16384. The -w option suppresses warnings. Although the mesh file format is binary, it is meant to be portable between machines. The only limitation is that machines with radically different integer sizes will not work together. DETAILS
The following Wavefront statements are understood and compiled by obj2mesh. v x y z A vertex location, given by its Cartesian coordinates. The final mesh position may of course be modified by the transform argu- ments given to the mesh primitive in the Radiance scene description. vn dx dy dz A vertex normal vector, given by its three direction components, which will be normalized by obj2mesh. Normals will be interpo- lated over the mesh during rendering to produce a smooth surface. If no vertex normals are present, the mesh will appear tesse- lated. A zero length normal (i.e., 0 0 0) will generate a syntax error. vt u v A local vertex texture coordinate. These coordinates will be interpolated and passed to the "Lu" and "Lv" variables during ren- dering. Local coordinates can extend over any desired range of values. usemtl mname A material name. The following faces will use the named material, which is taken from the material definitions in the -a input file(s). g gname Group association. The following faces are associated with the named group. If no "usemtl" statement has been encountered, the current group is used for the surface material identifier. f v1/t1/n1 v2/t2/n2 v3/t3/n3 .. A polygonal face. Polygon vertices are specified as three indices separated by slashes ('/'). The first index is the vertex location, the second index is the local (u,v) texture coordinate, and the third index is the vertex surface normal. Positive indices count from the beginning of the input, where the first vertex position ( v statement) is numbered 1, and likewise for the first texture coordinate and the first surface normal. Negative indices count backward from the current position in the input, where -1 is the last vertex encountered, -2 is the one before that, etc. An index of 0 may be used for the vertex texture or normal to indicate none, or these may be left off entirely. All faces will be broken into triangles in the final mesh. Obj2mesh currently makes an unsafe assumption that faces are convex, which may result in odd results if they are not. All other statement types will be ignored on the input. Statements understood by obj2rad(1) will be ignored silently; other statements will generate a warning message after translation to indicate how much was missed. DIAGNOSTICS
There are four basic error types reported by obj2mesh: warning - a non-fatal input-related error fatal - an unrecoverable input-related error system - a system-related error internal - a fatal error related to program limitations consistency - a program-caused error Most errors are self-explanatory. However, the following internal errors should be mentioned: Set overflow in addobject (id) This error occurs when too many surfaces are close together in a scene. Sometimes a dense mesh can be accommodated by increasing the maximum resolution (by powers of two) using the -r option, but usually this error indicates something is wrong. Either too many surfaces are lying right on top of each other, or the bounding cube is inflated from disparate geometry in the input. Chances are, the face number "id" is near those causing the problem. Hash table overflow in fullnode This error is caused by too many surfaces, and there is little hope of compiling this mesh. EXAMPLES
To create a compiled triangle mesh from the scene file mesh.obj using materials from the file mesh.mat: obj2mesh -a mesh.mat mesh.obj mesh.rtm To use local coordinates to place a square tiled image on a mesh object: void colorpict tiled_pat 7 red green blue mytile.hdr . frac(Lu) frac(Lv) 0 0 tiled_pat plastic tiled_mat 0 0 5 .9 .9 .9 0 0 tiled_mat mesh tiled_mesh 1 mymesh.rtm 0 0 ENVIRONMENT
RAYPATH the directories to search for material files. AUTHOR
Greg Ward SEE ALSO
gensurf(1), getinfo(1), make(1), obj2rad(1), oconv(1), rpict(1), rvu(1), rtrace(1), xform(1) RADIANCE
03/11/03 OBJ2MESH(1)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy