Help!!....I need some sort of a formula!!

My application displays graphs from given data and I need to somehow get it to show between 8 and 12 tick marks on the x and y axis. They also have to be rational values i.e. 120.0 130.0 140.0, etc not like 120.25432 or 132.5363 or 143.94. The program can put the tick marks at regular intervals already but not rational values. I seem to need a tick mark everytime the integer part changes by 1, 2, 2.5, 5, 10, 20, 25 or 50. This sequence would repeat for hundreds: 100, 200, 250, 500, 1000, 2000, 2500, 5000 and so on for hundreds of thousands. I don't need ticks at 40, 60, 3500, etc unless these numbers fall naturally into the above sequence. This requirement also repeats for the fractional part as well: a tick every 0.1, 0.2, 0.25 or 0.5 units.
I need to find a formula for "every XXX" depending on the level of the sequence.
I would need between 8 and 12 ticks on a "normal" screen 800 x 600 pixels. E.g. if the graph runs horizontally between 0 and 841ms then the 1000-scale would be too rare. Same for 500, 250 and 200 scales. The 100 scale would be ok as this would display 8 ticks, but the 50, 25, 20, 10 scales, etc, would be too dense. I need a formula to automatically make the decision that the 100 scale would be the one to use.
The program also knows how to adjust the "base number" of ticks on the axis so that the labels don't run into each other. Possibly assume that base number of regular ticks plus/minus 20% of that number. E.g. 8 to 12 ticks become 10 ticks +/- (20% of 10 == 2) == 10 +/- 2 ticks. If user reduces the window, the base number may become 5 or 4. In that case the scale will be 5 +/- 1 tick or 4 +/- 1 tick (20% of 4 == 0.8 approx 1).
Your help would be really, really appreciated as this needs to be sorted in the next week or two and I'm really stuck with this one!!
Thanks!!

To determine which scale to use first find the span of your axis Sx = Xmax-Xmin. You need to find which increment, when multiplied by the number of ticks N you wish to display, will cover this span.
The pattern of numbers that you specify (1,2,2.5...) is not a regular pattern and therefore cannot be elegantly implemented with a simple formula. You need to create a lookup array that contains these values, then create your series by scaling that array by powers of ten.
Start at an arbitrary scale, say, dx = 1 and find out if N * dx > Sx. If so, reduce dx to the next lowest increment in your series and repeat until N * dx > Sx is no longer true.
If N * dx < Sx you need to increase dx and repeat until you achieve N * dx > Sx. Your previous value of dx will be your "magic increment".
Hope this helps. Good luck!

Similar Messages

  • Right clicking - I need some sort of driver...

    Hello!
    Well, I recently acquired a new Logitech Wireless USB mouse, mainly for use with my Powerbook running Tiger. I currently have the USB reciever attached to my Keyboard, with I use for both the Powerbook and my 400mhz Sawtooth G4. Under OS 9, the G4 won't do a "right click" as I had assumed. I eventually realized that the reason I thought OS 9 had built-in 2 button mouse support was because I always used a 2-button Microsoft Mouse with my Macs running OS 9 - complete with the Microsoft driver. So, now I need some way to enable the right button to function as such....
    Is there any way to map modifier keys (eg, control+click) to mouse buttons under OS 9, or do I need third-party software?
    Thanks,
    -Dan

    Logitech seems to have Mac OS 9 drivers for their cordless mouse.
    http://www.logitech.com/index.cfm/428/958&cl=us,en?osid=12
    Is that the same model? I just picked one of them, so their may be others.
    And no, Mac OS 9 does not have built-in support for the "right click."

  • Need some sort of help: Solaris 9 (intel)

    After numerous attempts to install Video drivers etc. and by recomended instruction "press F2 for the test" I have got the freezing system. After reboot I have got:
    System is ready.
    Console Login:
    Starting Desktop login on Display 0:...
    Wait for desktop login screen before loggin in
    and freeze again... nothing happens; I cannot type login, etc.
    How I can resolve this problem at lease make this CDE disabled if I cannot login. :(
    One most radical solution -- reinstall I know :)
    Alex.
    PS my video card is TSENG LABS ET4000/W32P

    I built initpcic (XIGSpcic) packages that install on Solaris 10 x86, however it still doesn't plumb the underlying 3c589 card.
    The packages are available at
    ftp://ftp.sun.drydog.com/ftp/pub/solaris
    ftp://ftp.sun.drydog.com/ftp/pub/solaris/initpcic-1.7-sol10.pkg
    ftp://ftp.sun.drydog.com/ftp/pub/solaris/initpcic-1.7-sol10.src.tar.
    Has anyone figured out how to configure it? The DCA (Device Configuration Assistant) is no longer available with Solaris 10 (Solaris 10 06/06 and 12/06).

  • HELP I need some help choosing the right laptop

    Hello there. I am a student and I am looking to buy a Apple laptop. I have around 700GBP to spend, but I do not wish to spend all of that. As I do not use Macs that often I dont think I need the newer Macbooks or the Macbook Pros as I feel that it is a waste of power. My friend said the 12" Powerbook was the way to go. There are several different models out there and I was wondering if anyone could help me choose one. It will be used mostly for word processing and admin based work, but I would like to have enough power to be able to run some graphic based activities. I wont be using high level apps that much but it would be nice to know if the opportunity was there, then i I have sufficient power to be able to run them. My friend said an 867mhz G4 with upgraded hdd and ram would do the trick, but I have found out that the specs range all the way up to 1.5ghz. I like the look of the powerbook and I have heard they are more reliable than an ibook which is why I dont really want to choose one of those. Thanks for any help!

    The biggest advantage of the 12PB is its portability, but you didn't include that in your specs.
    The graphics are very good for the small screen. If you need more intense graphics you should consider a larger screen.
    I use mine for mostly word processing and e-mail. I am also the IT guy in my small office and I manage networked PCs from my PB. I use an external monitor and screen spanning for extra work area. I thought long and hard before I bought my PB, as I had used PCs extensively all my life. The configuration that was recommended to you will work fine.

  • I am making a commercial for a contest. Can I use the iMovie music "Acoustic Sunrise" for free, or do I need some sort of permission?

    I just need a clear, understadable answer on this in lamens terms. I am putting together a short video to be entered into a commercial contest. If picked as a winner, it would be used as an online commercial. Can I use one of the iMovie songs "Acoustic Sunrise" without having to pay a fee, or asking for permission? Are all the songs/sound effects that come with iMovie mine to use without a fee/permission?
    I can't seem to find a clear answer on this. I tried reading the agreement, but forgive me, I am still not 100% sure what I can and can't do.
    Thanks to all help!

    Yes you can - maybe.
    These are all free to use, as clearly stated in section 2.C of the iLife Software License Agreement:
    “You may use the Apple and third party audio content (“Audio Content”) contained in or otherwise included with the Apple software, on a royalty-free basis, to create your own original soundtracks for your video and audio projects. You may broadcast and/or distribute your own soundtracks that were created using the Audio Content, however, individual samples, sound sets, or audio content may not be commercially or otherwise distributed on a standalone basis, nor may they be repackaged in whole or in part as audio samples, sound files, sound effects or music beds.”
    http://images.apple.com/legal/sla/docs/ilife09.pdf
    You may need to contact Apple Legal:
    http://www.apple.com/legal

  • Help! Need some files.

    Need these files ==> 1/ Map called "english male" => Contains the audio files, of the male voice navigation commands.
    2/ The XML Document "config"
    Anyone who still has the male voice guidance during navigation, could be a donor :-)
    These files can be found on your memory card.
    To locate these files, please follow these simple steps ==>
    1/ Connect your Nokia N95 to your PC using the provided USB cable.
    2/ Choose for connection type A/ mass storage or B/ data transfer.
    3/ Locate in Windows Explorer your memory card, the memory card should be displayed as a hard drive.
    4/ Then to locate the files go to the following maps *Private *20001f63 *English
    5/ The map "English" contains the files I need A/ map called "english male" & B/ the XML Document "config"
    Can anyone PLEASE post these files, or send them to me by E-mail ?
    This way I can restore the previous audio files for English male voice navigation commands.
    I want to get rid of the female voice commands witch I have now.
    Any help would be highly appreciated.
    Best Regards,
    Marc.

    Will gladly send you the male files if you have the female files

  • Home media server for mac, that you can also get to remotely.  Any ideas?  I am out of space on my macbook pro hard drive and appletv.  Need some sort of media server for delivery to macs, ipods, ipads, etc.  Any suggestions?

    Hi,
    I have been using my macbook pro as a home media server, hosting most content on the macbook with ipod touch, ipads, and appletv streaming/sharing content.  I have run out of space on both the macbook pro and the apple tv and am looking to moving the content to a home media server.  Any thoughts/suggestions?  I'd like something that I can access remotely too.  I have an old slingbox and also have a static IP address.
    Any thoughts/suggestions would be most welcome!

    Don't worry I've sorted it! I just had to turn off Reminders as well in iCloud. Calendar then worked fine, even when I turned Calendar and Reminders back on.

  • Help,..Need some suggestions from organized iTunes users

    A couple of simple questions.
    1. I have 5000 songs. A total unorginised mess where many are not labeled completly or correctly ( missing album or named incorrectly with band and title in the name box or worse with a number preceeding the whole name ).
    All songs are listed under music Library in one big list.
    MY 1st QUESTION IS,
    what would be the best way todeal with this mess and orginze it
    2. I have songs and albums I have downloaded or songs from cd's I have in a folder that is not my main music folder.
    MY 2nd QUESTION IS,
    what the best way to get these in the itunes music folder and recognised by itunes.
    3. My 5 gig ipod is in the same mess, any advice on cleaning it up.
    Thanks for any help or suggestions

    The iTunes library refers to 2 things.
    It's all the music you see when you open iTunes and click on Library.
    It is also a file in iTunes folder, which contains and the song info, playlist, ratings, etc.
    Playlists are simply a list of songs in the library.
    If song is not displayed in iTunes when you select Library, it is not in iTunes.
    The iTunes music folder is not the iTunes library.
    The music in that folder should be in the library, but it is not the library itself.
    If you have songs on your computer and you cannot see them in the iTunes app, use File -> Add file {or folder} to library.
    Once you have all your music in iTunes, follow the stpes to consolidate. This copies everything which shows up when you select Library in iTunes to the location in iTunes prefs -> Advanced.
    Once this is done, select Library in iTunes.
    Everything you see here (and only what you see here), will be in the new folder in iTunes prefs -> Advanced.
    You can then delete all the music files in any other location on your computer.

  • I need some sort of a Timer ..

    How are you doing ... I'm making a game for my gr 12 class, Target Practice crap, very simple. I don't know how to get the target to stay up for a certain amount of time, and then dissapear at a next random spot, OR dissapear if it's clicked on ... if you helped me, I would really appreciate it .. here's my code: (If anyone feels like ripping it off, I'd be honored :) )
    import java.applet.*;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.util.*;
    public class GameVersion2 extends Applet implements Runnable
    //Initial crap
    private Image dbImage, top;
    private int xPosition = 0, yPosition = 0;
    private Random rand = new Random ();
    private int scoreCount = 0, otherCounts = 0;
    private int count = 0;
    Date startTime;
    Date clickTime;
    public void start ()
    Thread th = new Thread (this);
    th.start ();
    Thread th2 = new Thread (this);
    th2.start (); // Stop thread for 20 milliseconds
    public void init ()
    dbImage = getImage (getCodeBase (), "warning.gif");
    top = getImage (getCodeBase (), "Top.gif");
    public void run ()
    this.getXYPositions ();
    public void getXYPositions ()
    xPosition = 10 + (Math.abs (rand.nextInt ()) % 750); //determines where the picture will appear x wise; 10<x<760
    yPosition = 120 + (Math.abs (rand.nextInt ()) % 340); //determines where the picture will appear y wise; 120<x<460
    startTime = new Date ();
    public void paint (Graphics g)
    g.setColor (Color.blue);
    g.drawRect (10, 120, 780, 370);
    g.drawImage (top, 78, 2, this);
    g.drawImage (dbImage, xPosition, yPosition, this);
    g.drawString ("Your Score is: " + scoreCount, 20, 510);
    g.drawString ("The time is " + startTime, 20, 580);
    showStatus ("TargetPractice");
    try
    Thread.sleep (820);
    catch (InterruptedException ex)
    // do nothing
    public boolean mouseDown (Event e, int x, int y)
    if (((xPosition + 30) > x && x > xPosition) && ((yPosition + 30) > y && y > yPosition))
    scoreCount++;
    this.getXYPositions ();
    repaint ();
    else
    this.getXYPositions ();
    repaint ();
    return true;

    Hmmm,
    looking at the comments above I'm not sure how much of this is your own code ... oh well, I've rewritten your Thread part so that you image now jumps around a bit. ActionEvents with a boolean are deprecated and you Date() method could be seriously improved too. Please look these up, do a search at the 'new to' forum or 'java programming' forum and try and implement them yourself (much more fun).
    Ce la vie - and in good faith!import java.applet.*;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.util.*;
    public class junk extends Applet implements Runnable{
         //Initial crap
         private Image dbImage, top;
         private int xPosition = 0, yPosition = 0;
         private Random rand = new Random ();
         private int scoreCount = 0, missCount = 0;
         private int count = 0;
         Date startTime;
         Date clickTime;
       Thread picture = null;
       boolean started = true;
         public void init(){
              dbImage = getImage (getCodeBase (), "A.gif");
              top = getImage (getCodeBase (), "B.gif");
         public void start(){
          if(picture == null) {
             picture = new Thread(this, "junk");
             picture.start();
         public void run(){
          Thread thread = Thread.currentThread();
          while (picture == thread){
                   try{
                while(started){
                           Thread.sleep (1000);
                   getXYPositions();
                   repaint();
                   catch (InterruptedException ex){}
         public void getXYPositions(){
              xPosition = 10 + (Math.abs (rand.nextInt ()) % 750);
              yPosition = 120 + (Math.abs (rand.nextInt ()) % 340);
         public void paint(Graphics g){
              g.setColor (Color.blue);
              g.drawRect (10, 120, 780, 370);
              g.drawImage (top, 78, 2, this);
              g.drawString ("Your Score is: " + scoreCount, 20, 510);
              g.drawString ("Misses: " + missCount, 220, 510);
              g.drawString ("The time is " + startTime, 20, 580);
              showStatus ("TargetPractice");
              g.drawImage (dbImage, xPosition, yPosition, this);
         public boolean mouseDown(Event e, int x, int y){
              if (((xPosition + 30) > x && x > xPosition) &&
             ((yPosition + 30) > y && y > yPosition))    {
                   scoreCount++;
                   this.getXYPositions ();
                   repaint ();
              else{
                   this.getXYPositions ();
             missCount++;
                   repaint ();
         return true;
    }

  • Need some sort of SQL Server error log parser?

    I have over 100 MSSQL instances - ranging from SQL2000 - SQL2012.
    Currently, I'm querying using EXEC SP_ERRORLOG to read the log files. With the querying method, I cannot always be on top of things as I like. And frankly, I just check once a day for a period of 24 hours or so.
    I'm wondering if there's an utility / software / solutions out there that does the following:
    1) constantly monitors the error logs of all instances
    2) present the log files in an orderly manner for each instances as needed.
    3) email out a group of people for certain error / severity / state number. 
    Putting this in SQL Server Security because I'm mainly interested in errors like 18456 Login failed either from reboot or actual login failed.
    Thanks

    You can try that using Powershell
    srvr.txt should contain a list of servers, I would prefer same SQL version.
    Save the content to ReadingErrorlog.PS1
    param
    [String] $infile,
    [DateTime] $date,
    [int] $last,
    [String] $OutFile
    function getUNCPath($infile)
    $qualifier = Split-Path $infile -qualifier
    $drive = $qualifier.substring(0,1)
    $noqualifier = Split-Path $infile -noQualifier
    "$drive`$$noqualifier"
    $srvr=get-content c:\DBAScripts\srvr.txt
    foreach($svr in $srvr)
    $UNC=getUNCPath($infile)
    $readbuffer=get-content -path \\$svr\$UNC -encoding unicode | select-object -last $last
    $i=0
    [Datetime] $date
    [String] $Outbuffer
    $outbuffer=""
    foreach($line in $readbuffer)
    $i++;
    $mydate=$line.substring(0,22)
    Write-host $Mydate
    if ($line -ne "")
    if($mydate -ge $date)
    if ($line -like "*Error:*")
    write-output "$i: $line"
    $outbuffer=$outbuffer+$line
    add-content -path $outfile -value $outbuffer
    sample call
    PS:\>.\ReadingErrorlog.PS1  "f:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\errorlog"
     "2012-05-01 12:00:00.00"
     10  c:\DBAScripts\output.txt
    You may need to re-work on the code here and there.
    --Prashanth

  • Need some sorting Logic

    Hi Guys,
                 One field of my ITAB has the following values.
    PN
    0000001080-Z1-1 /12
    0000001080-Z1-2 /12
    0000001080-Z1-3 /12
    0000001080-Z1-4 /12
    0000001080-Z1-5 /12
    0000001080-Z1-6 /12
    0000001080-Z1-7 /12
    0000001080-Z1-8 /12
    0000001080-Z1-9 /12
    0000001080-Z1-10 /12
    0000001080-Z1-11 /12
    0000001080-Z1-12 /12
    When I am sorting this,its coming in the below way:-
    PN
    0000001080-Z1-1 /12
    0000001080-Z1-10 /12
    0000001080-Z1-11 /12
    0000001080-Z1-12 /12
    0000001080-Z1-2 /12
    0000001080-Z1-3 /12
    0000001080-Z1-4 /12
    0000001080-Z1-5 /12
    0000001080-Z1-6 /12
    0000001080-Z1-7 /12
    0000001080-Z1-8 /12
    0000001080-Z1-9 /12
    So I understood that its is considering only the first digit after Z1.
    I want this in correct sequential order.How to do this.
    Thanks,
    Prasad.

    0000001080-Z1-1 /12
    0000001080-Z1-2 /12
    0000001080-Z1-3 /12
    0000001080-Z1-4 /12
    0000001080-Z1-5 /12
    0000001080-Z1-6 /12
    0000001080-Z1-7 /12
    0000001080-Z1-8 /12
    0000001080-Z1-9 /12
    0000001080-Z1-10 /12
    0000001080-Z1-11 /12
    0000001080-Z1-12 /12
    create an additional numerical field in your internal table and store the last numerical part in it (the part behind Z1- )
    0000001080-Z1-1 /12   1
    0000001080-Z1-2 /12   2
    0000001080-Z1-3 /12   3
    0000001080-Z1-4 /12   4
    0000001080-Z1-5 /12   5
    0000001080-Z1-6 /12   6
    0000001080-Z1-7 /12   7
    0000001080-Z1-8 /12   8
    0000001080-Z1-9 /12   9
    0000001080-Z1-10 /12  10
    0000001080-Z1-11 /12  11
    0000001080-Z1-12 /12  12
    Then sort on that field.
    But best would be: split up the complete value into separate fields and include those fields in your internal table.
    Example:
    original                        f1                  f2    f3  f4
    0000001080-Z1-1 /12    0000001080   Z1   1   /12 
    Now you can sort on f1, f2, f3 and f4.
    Edited by: Maen Anachronos on Apr 8, 2009 4:33 PM

  • Help I need some advice on my macbook and the sims 2!!!

    ive just bought a brand new macbook! it's very fast and everything's fine, but I was just wondering if it will be able to play the sims 2? I want to buy the mac version but will it have enough memory, processor power etc. Ive checked the system preferences and my laptop fits them all fine! but I was just wondering!
    Has anyone else got a mac laptop and can play the sims 2 on it?
    would be much appreciated!!!!!!!
    Macbook   Mac OS X (10.4.8)  

    i have a macbook and i was able to play sims 2 perfectly fine. i heard there would be problems since it has a shared media card, and that i would have to put the resolution of the game on to the lowest level, but i havent and it runs just as well as it would on any other computer.

  • INaviX marine navigation on ipad2.  Need some sort of anti-glare screen

    I am running iNaviX marine navigation software on my iPad2.  I can't see the charts due to the glare.  Does someone have an anti-glare screen that will allow me to see the screen?

    There are many anti-glare screen products available, ranging from "pricey" US$30 or more to "inexpensive" under US$10.
    If you're in a hurry, major electronics chains and Apple Stores usually have the pricey ones in stock. I found a high quality anti-glare screen online from www.handhelditems.com for well under $10. In two months of moderate daily use, it is not wearing or coming loose.  But I'm not in a marine environment.
    HHI offers several kinds, sold singly and in multiples.  Search for "HHI Crystal Clear Screen Protector For iPad 2 and iPad 1"
    This is the one I purchased: http://www.handhelditems.com/ipad-antifingerprint-antiglare-matte-finishing-scre en-protector-free-handhelditems-stylus-p-161160.html
    Since you are in a marine environment, I suggest that you investigate whether accident protection insurance coverage would be worthwhile. If it's personal use, you might be able to add coverage via homeowners insurance.

  • We Need Some Developer Recognition Here

    Forgive me if I missed something of this sort, but it seems to me that we need some sort of "About the Developers" page. Looking around, I have very little idea of who the devs are anymore, and I think they need more recognition for their work. Just throwing this out there, it's a feeling I've had for a while.

    Gah, I've been proven an idiot within 10 minutes. Oh well, it's happened before.
    EDIT: LOL, now I get the joke behind Iphitus' avatar.
    Last edited by arew264 (2008-08-17 17:03:56)

  • Create some sort of blurring

    Hi!
    i think that indesign need some sort of blurring, and it's pain in *** if i need to open photoshop for every image and apply filter to get some sort of blurring...

    http://en.wikipedia.org/wiki/List_of_sc … ware#Linux
    Oh sorry I didn't see the part where you wanted it as a webcam for Skype. I didn't know such a thing exists unless one of the above listed programs have that feature.
    Last edited by sand_man (2009-06-25 11:17:30)

Maybe you are looking for

  • Brand new ipod touch won't display home page

    Hi Folks Just bought 2 new Ipod Touch's for the kids for xmas. One turns on fine and went straight to the home page and allowed me to personalise it but the other one starts up and just displays a picture of the USB cable and an upward arrow pointing

  • JVC GZ-HD7E (.TOD) vs. Final Cut Pro 7

    The Mac world is really new to me, I have iMac, I have Final Cut Studio HD (the latest and updatet) and I have JVC GZ-HD7E camera - but they dont work together I thought that this huge program would take .tod files but neither FCP or iMove likes thes

  • OWB Implmentation Model Assistance

    We have developed an implementation model which segments development design from production design into two design repositories. The method of moving to production is Metadata Export/Metadata Import between the two design repositories. The developmen

  • BI Integration with ADF

    I am able to run the ADF Application(BI Reports integration) successful on integrated server by doing the below things, 1) installed all required libraries 2) created a BI connection under Application Resources connections 3) created a sample applica

  • Can't attach Numbers file to e mail

    Hi.....since updating the Numbers program on my late 2013 Mac Book Pro Retina I have been unable to attach small Numbers files (circa 1Mb) to either my Hotmail (Outlook) or Gmail e mail accounts. Within Hotmail I get the message   'There was an error