Moving axis

This is a discussion on Moving axis within the C Programming forums, part of the General Programming Boards category; I'm having real trouble in finding a way of moving an axis relative to a fixed point. The axis will ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Question Moving axis

    I'm having real trouble in finding a way of moving an axis relative to a fixed point. The axis will represent different lengths in metres. The fixed point is a marker indicating the the length.

    length
    |
    ====100====200====300====400====500====600====700

    This is what i need it to look like except i need the numbers to not be visible after these points i.e if the length changed to 300, 100 and 200 would not be visible anymore but 800 and 900 would be.

    The length is being read from a file as a string and the counter changes every 0.5seconds

    Thanks

  2. #2
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Dood, I've barely an idea of what you're asking.

    Post some source code maybe? Maybe tell us the big picture you're trying to accomplish?
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    void display( int offset, int width )
    {
        /* ?= N ===== N =? */
        int x = 0;
    
        /* prepadding */
        for( x = offsest % 5; x > 0; x-- )
            putchar( '=' );
        printf( "%d", 10 * offset++  );
        for( x = 0; x < 5; x++ )
            putchar( '=' );
        printf( "%d", 10 * offset++  );
        /* postpadding */
        for( x = (offsest + width) % 5; x > 0; x-- )
            putchar( '=' );
    }
    I think that's the general idea of what you're trying to do. Now naturally you'd want to use some looping in the center if you had a different amount of repeating to do there of your complete segments.
    Quote Originally Posted by Babkockdood View Post
    Post some source code maybe? Maybe tell us the big picture you're trying to accomplish?
    He's basically trying to display a floating window of text. Consider a string that is the alphabet: "abcdefghij...z". You want to display 5 characters at a time, at any given spot on that string.
    Code:
    printf("%5s", alphabet + (offset > 21 ? 22 : offset < 0 ? 0 : offset) );
    That should give you a five character chunk of your alphabet string, based on whatever offeset you want to start on, without running off each end.



    Quzah.
    Last edited by quzah; 02-25-2011 at 06:30 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-24-2007, 12:05 AM
  2. need help making a dot bounce up and down y axis in this prog
    By redwing26 in forum Game Programming
    Replies: 10
    Last Post: 08-05-2006, 01:48 PM
  3. moving median function
    By supermeew in forum C Programming
    Replies: 0
    Last Post: 05-04-2006, 03:37 PM
  4. AXIS and C++
    By bman1176 in forum C++ Programming
    Replies: 0
    Last Post: 03-29-2006, 11:00 AM
  5. 3D moving
    By bluehead in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2005, 05:46 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21