View unanswered posts | View active topics It is currently Wed Jun 20, 2018 1:32 am

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Inverting a circle
Author Message
Rookie

Joined: Sun May 16, 2010 3:31 pm
Posts: 10
Inverting a circle
I use this code:
 Code:nxtEraseEllipse(x-radius, y-radius, x+radius, y+radius);nxtDrawEllipse (x-radius, y-radius, x+radius, y+radius);nxtDisplayStringAt(buttons[ID].xText, buttons[ID].yText, "%s", buttons[ID].text);if (checkButton(ID)) {    for (int i=-radius; i<=radius; i++) nxtInvertLine(x-sqrt(radius*radius-i*i), y+i, x+sqrt(radius*radius-i*i), y+i);}

But when checkButton(ID)=true there are some not inverted pixels to the right of the circle:

 Attachments: File comment: checkButton(ID)=true c2.JPG [ 2.57 KiB | Viewed 3618 times ] File comment: checkButton(ID)=false c1.JPG [ 2.31 KiB | Viewed 3618 times ]
Fri May 21, 2010 3:27 am
Rookie

Joined: Sun May 16, 2010 3:31 pm
Posts: 10
Re: Inverting a circle
It works!
But I don't understand why it works...
I changed
 Code:for (int i=-radius; i<=radius; i++) nxtInvertLine(x-sqrt(radius*radius-i*i), y+i, x+sqrt(radius*radius-i*i), y+i);

to
 Code:for (int i=-radius; i<=radius; i++) nxtInvertLine(x-sqrt(radius*(radius+1)-i*i)+1, y+i, x+sqrt(radius*(radius+1)-i*i), y+i);

Fri May 21, 2010 3:50 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.