Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > nested for/while loops

Reply
Thread Tools

nested for/while loops

 
 
ahso
Guest
Posts: n/a
 
      12-04-2011
Hi
a function returns Z (height) after giving X and Y location. How
would those two for (or while?) loops look like if I need all z points
in a rectangle.
Many thanks
Michael

 
Reply With Quote
 
 
 
 
ralph
Guest
Posts: n/a
 
      12-04-2011
On Sun, 4 Dec 2011 07:04:41 -0800 (PST), ahso <(E-Mail Removed)>
wrote:

>Hi
> a function returns Z (height) after giving X and Y location. How
>would those two for (or while?) loops look like if I need all z points
>in a rectangle.
>Many thanks
>Michael


I'm probably missing something as that question doesn't make any
sense.

Even assuming each "X" and "Y" describes a point. Everything else
would be simple linear addition or substraction.

Need more info.

-ralph
 
Reply With Quote
 
 
 
 
Nick Keighley
Guest
Posts: n/a
 
      12-04-2011
On Dec 4, 3:04*pm, ahso <(E-Mail Removed)> wrote:
> Hi
> *a function returns Z (height) after giving X and Y location. How
> would those two for (or while?) loops look like if I need all z points
> in a rectangle.
> Many thanks
> Michael


you need to work out how X,Y gets turned into Z
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      12-04-2011
On 12/4/2011 12:23 PM, Nick Keighley wrote:
> On Dec 4, 3:04 pm, ahso<(E-Mail Removed)> wrote:
>> Hi
>> a function returns Z (height) after giving X and Y location. How
>> would those two for (or while?) loops look like if I need all z points
>> in a rectangle.
>> Many thanks
>> Michael

>
> you need to work out how X,Y gets turned into Z


No, [s]he needs to work out how "a rectangle" turns into X and Y.

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
ahso
Guest
Posts: n/a
 
      12-05-2011
Ok it's a little more complicated:
---
Probes the terrain. Pass in the XYZ coordinate of the probe point...
Other fields are filled in if we hit terrain, and a probe result
* is returned.
----
So i give that function x,y,z coordinates and if it hits terrain I get
a result. Now I see why i only get a few points to draw as it hits
around the viewer but loses ground contact in the mountains etc.
I want to get the z (ground contact) within a 128x128 square around my
position, for a heightmap. (color z in different colors)
Many thanks indeed as I'm stuck...
Regards Michael

 
Reply With Quote
 
Werner
Guest
Posts: n/a
 
      12-05-2011
On Dec 5, 8:56*am, ahso <(E-Mail Removed)> wrote:


> Many thanks indeed as I'm stuck...
> Regards Michael


Post some code...
 
Reply With Quote
 
ahso
Guest
Posts: n/a
 
      12-05-2011
Getting closer, now I have lines from top left to bottom right:

for( int x=0; x< 16384; x++ ){
draw x,y,z

I need also a y for loop?
Thanks
Michael


 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      12-05-2011
On 12/5/2011 9:19 AM, ahso wrote:
> Getting closer, now I have lines from top left to bottom right:
>
> for( int x=0; x< 16384; x++ ){
> draw x,y,z
>
> I need also a y for loop?
> Thanks
> Michael


Michael,

You need to sit down and write your algorithm with a pencil on a piece
of paper. "I have lines from top left to bottom right" - what does that
mean? We have no idea. It's not a description of an algorithm.
Perhaps you need to think about the algorithm for a while. Perhaps you
should also look into some *formality* in your activities. So far your
posts indicate that your work is very hap-hazard. Step back from
programming for an hour and think what actions you would take if you
were the computer and you needed to accomplish whatever goal you're
setting for it.

To make tea, what do you need? You need a cup, water source, dry tea
(loose or in a bag) and a way to heat the water to the boiling point.
Water source is in the kitchen (or the bathroom). So, as part of the
algorithm for making tea you need to ensure you're in one of those
locations. To boil water you need some energy source. A microwave
would do (make sure it's plugged into an electrical outlet). And so on.
You write down preconditions, then you write down your actions. It
becomes the algorithm for accomplishing your goal.

Same thing with making calculations. Or drawing a shape. Or
controlling a nuclear reactor. You need the algorithm first, THEN you
can put it in terms of the language you've chosen to implement it.

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
ahso
Guest
Posts: n/a
 
      12-06-2011
Look for yourself, your comments are all sick...
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      12-06-2011
On 12/ 6/11 08:07 PM, ahso wrote:
> Look for yourself, your comments are all sick...


Who should look? What comments?

Don't snip context.

--
Ian Collins
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loops with loops using html-template Me Perl Misc 2 01-12-2006 05:07 PM
nested loops and conditional statements Porthos XML 3 02-07-2005 08:47 PM
dynamic number of nested loops Allan Bruce Java 5 07-03-2004 09:12 PM
break or continue out of nested loops viza C Programming 5 07-17-2003 04:04 AM
compacting similar nested for loops SplaTTer C++ 2 07-02-2003 09:16 PM



Advertisments