Problem with this excercise problem. 
Author Message
 Problem with this excercise problem.

Hey, guys it is my first time posting.  I am having trouble with this
problem for my computer science - scheme class.  (this site is our
textbook online) http://www.*-*-*.com/
problem 6.6.3.  You must follow the first 2 problems to understand it.
Exercise 6.6.3

Use the template fun-for-circle to develop in-circle?. The function
consumes a circle structure and a posn and determines whether or not
the pixel is inside the circle. All pixels whose distance to the
center is less or equal to the radius are inside the circle; the
others are outside.

Consider the circle in figure . The circle's center is (make-posn 6
2), its radius is 1. The pixel labeled A, located at (make-posn 6
1.5), is inside the circle. The pixel labeled B, located at (make-posn
8 6), is outside.

Anyway, I know that I am supposed to find the distance of the point
entered from the center of the circle.  I am not sure what to do. Here
is what I have done so far.  The error I get is:
illegal application: first term in application is a function-bound
identifier.  Then it circle a-posn in (sqr (a-posn)))) at the bottom.

;; 6.6.1
(start 300 300)
;; Data Definitions:
(define-struct circle (center radius color))
;; Circle is a structure: (draw-a-circle ((make-posn 30 20) 50 'red):
(make-posn 30 20) is a posn, 50 is anumber, 'red is a symbol.

;; Template:
;; (define (fun-for-circle a-circle)
;; ...(circle-center a-circle)...
;; ...(circle-radius a-circle)...
;; ...(circle-color a-circle)...)

;; 6.6.2
;; Contract: draw-a-circle: circle -> boolean
;; Purpose: consumes circle structure and draws the corresponding
circle on the screen.
(define (draw-a-circle a-circle)
  (draw-circle (circle-center a-circle) (circle-radius a-circle)
(circle-color a-circle)))

;; 6.6.3
;; Contract: in-circle?: circle posn -> boolean
;; Purpose: determine whether or not the pixel is inside the circle.
(define (in-circle? a-circle a-posn)
  (draw-circle (circle-center a-circle) (circle-radius a-circle)
(circle-color a-circle)
  (sqrt
    (+ (sqr (circle-center a-circle))
       (sqr (a-posn))))
  (cond
    [(<= a-posn (draw-a-circle (circle-radius))) 'inside-circle])))

Can you keep in mind that I have only done up to that chapter in the
book.  You can look on the site to see where I am.



Thu, 01 Jul 2004 11:29:10 GMT  
 Problem with this excercise problem.

Quote:

> Hey, guys it is my first time posting.  I am having trouble with this
> problem for my computer science - scheme class.  (this site is our
> textbook online) http://www.htdp.org/2001-11-21/Book/node32.htm
> problem 6.6.3.
> ;; 6.6.3
> ;; Contract: in-circle?: circle posn -> boolean
> ;; Purpose: determine whether or not the pixel is inside the circle.
> (define (in-circle? a-circle a-posn)
>   (draw-circle (circle-center a-circle) (circle-radius a-circle)
> (circle-color a-circle)
>   (sqrt
>     (+ (sqr (circle-center a-circle))
>        (sqr (a-posn))))
>   (cond
>     [(<= a-posn (draw-a-circle (circle-radius))) 'inside-circle])))

> Can you keep in mind that I have only done up to that chapter in the
> book.  You can look on the site to see where I am.

I'm afraid your attempt indicates that you are more than a gentle
nudge away from solving this problem.  At this point, I doubt that you
will find reading this newsgroup to be any more enlightening than
reading the text of your textbook was.

I'm glad you have the initiative to seek help here, but I think what
you should be pursuing is live, interactive help from your instructors
and their assistants.

-al



Thu, 01 Jul 2004 14:29:17 GMT  
 Problem with this excercise problem.

Quote:

> Hey, guys it is my first time posting.  I am having trouble with this
> problem for my computer science - scheme class.  (this site is our
> textbook online) http://www.htdp.org/2001-11-21/Book/node32.htm
> problem 6.6.3.  You must follow the first 2 problems to understand it.
> Exercise 6.6.3

> Use the template fun-for-circle to develop in-circle?. The function
> consumes a circle structure and a posn and determines whether or not
> the pixel is inside the circle. All pixels whose distance to the
> center is less or equal to the radius are inside the circle; the
> others are outside.

> Consider the circle in figure . The circle's center is (make-posn 6
> 2), its radius is 1. The pixel labeled A, located at (make-posn 6
> 1.5), is inside the circle. The pixel labeled B, located at (make-posn
> 8 6), is outside.

> Anyway, I know that I am supposed to find the distance of the point
> entered from the center of the circle.  I am not sure what to do. Here
> is what I have done so far.  The error I get is:
> illegal application: first term in application is a function-bound
> identifier.  Then it circle a-posn in (sqr (a-posn)))) at the bottom.

> ;; 6.6.1
> (start 300 300)
> ;; Data Definitions:
> (define-struct circle (center radius color))
> ;; Circle is a structure: (draw-a-circle ((make-posn 30 20) 50 'red):
> (make-posn 30 20) is a posn, 50 is anumber, 'red is a symbol.

> ;; Template:
> ;; (define (fun-for-circle a-circle)
> ;; ...(circle-center a-circle)...
> ;; ...(circle-radius a-circle)...
> ;; ...(circle-color a-circle)...)

> ;; 6.6.2
> ;; Contract: draw-a-circle: circle -> boolean
> ;; Purpose: consumes circle structure and draws the corresponding
> circle on the screen.
> (define (draw-a-circle a-circle)
>   (draw-circle (circle-center a-circle) (circle-radius a-circle)
> (circle-color a-circle)))

> ;; 6.6.3
> ;; Contract: in-circle?: circle posn -> boolean
> ;; Purpose: determine whether or not the pixel is inside the circle.
> (define (in-circle? a-circle a-posn)
>   (draw-circle (circle-center a-circle) (circle-radius a-circle)
> (circle-color a-circle)
>   (sqrt
>     (+ (sqr (circle-center a-circle))
>        (sqr (a-posn))))
>   (cond
>     [(<= a-posn (draw-a-circle (circle-radius))) 'inside-circle])))

> Can you keep in mind that I have only done up to that chapter in the
> book.  You can look on the site to see where I am.

CAN YOU PLEASE HELP ME?!?!? THESE EXERCISES ARE SUPPOSED TO BE IN
PLACE OF MY MIDTERM.


Thu, 01 Jul 2004 14:34:33 GMT  
 Problem with this excercise problem.

Quote:

> ;; 6.6.3
> ;; Contract: in-circle?: circle posn -> boolean
> ;; Purpose: determine whether or not the pixel is inside the circle.
> (define (in-circle? a-circle a-posn)
>   (draw-circle (circle-center a-circle) (circle-radius a-circle)
> (circle-color a-circle)
>   (sqrt
>     (+ (sqr (circle-center a-circle))
>        (sqr (a-posn))))
>   (cond
>     [(<= a-posn (draw-a-circle (circle-radius))) 'inside-circle])))

> Can you keep in mind that I have only done up to that chapter in the
> book.  You can look on the site to see where I am.

Well the you are confusing different tasks. The specificaton of
in-circle? is clear you give it a circle and another point and should
calculate if the point is in the circle or not. No drawing etc should
take place in the function in-circle?. I'm rusty on mathematics so I
do not know how to calculate if a point is in a circle. You should
look after it and than just "translate" it into Scheme. You'll be done
than.

Regards
Friedrich



Thu, 01 Jul 2004 16:17:48 GMT  
 Problem with this excercise problem.

Quote:
> CAN YOU PLEASE HELP ME?!?!? THESE EXERCISES ARE SUPPOSED TO BE IN
> PLACE OF MY MIDTERM.

really, by asking us to do this for you (or even some of it) you are
probably violating the academic integrity policy of your department...you
should seek help from your instructors....if you have{*filter*}ed off the
semester, it's entirely okay to go to your instructors and say so...they
will probably give you more help then in order to help you make it
through...


Thu, 01 Jul 2004 22:46:34 GMT  
 Problem with this excercise problem.


Quote:
>> CAN YOU PLEASE HELP ME?!?!? THESE EXERCISES ARE SUPPOSED TO BE IN
>> PLACE OF MY MIDTERM.

>really, by asking us to do this for you (or even some of it) you are
>probably violating the academic integrity policy of your department

There is no probably about it there is no University that tolerates
such activity. The guy already knows this, that's why he doesn't
use his University account.
Quote:
>...you
>should seek help from your instructors....if you have{*filter*}ed off the
>semester, it's entirely okay to go to your instructors and say so...they
>will probably give you more help then in order to help you make it
>through...

I'm not familiar optionline.net, I presume it is some free email
service that alows people to use a different email address from their
standard. If he did do this, and he gave optionline any correct
information, then he is risking optionline getting a complaint
and deciding that they don't like students using their acounts to
cheat and may turn him over to the University.

Or even nastier, someone may respond with what seems to be a
legitimate answer but with a suble well hidden bug that is
distinguishable. If he submits anything he got from here
and his instructor browses the group, he may very well get caught.



Thu, 01 Jul 2004 23:27:12 GMT  
 Problem with this excercise problem.
I am a student that is in high school.  My instructor says that you
can get all the outside help you need, as long as you follow the book,
and don't do any coding to solve problems that the book has not yet
covered.  This is exercise (my book is also online)
http://www.htdp.org/2001-11-21/Book/node32.htm.


Fri, 02 Jul 2004 01:07:09 GMT  
 Problem with this excercise problem.

Quote:
> I'm not familiar optionline.net, I presume it is some free email
> service that alows people to use a different email address from their
> standard. If he did do this, and he gave optionline any correct
> information, then he is risking optionline getting a complaint
> and deciding that they don't like students using their acounts to
> cheat and may turn him over to the University.

Optimum Online is a cable ISP that serves various parts of NY and CT.
They allow 5 email addresses per paid account.

This is off the subject, but I highly doubt any ISP would get involved
in matters like these unless they concerned actual illegal activity.

--David



Fri, 02 Jul 2004 04:55:07 GMT  
 Problem with this excercise problem.

Quote:

> I am a student that is in high school.  My instructor says that you
> can get all the outside help you need, as long as you follow the book,
> and don't do any coding to solve problems that the book has not yet
> covered.  This is exercise (my book is also online)
> http://www.htdp.org/2001-11-21/Book/node32.htm.

I can't see what this posting has to do with the answer I posted. I
posted that you are confusing some things and tried to put them
straigt. So please do that and if you *than* have problems you should
post again

Friedrich



Fri, 02 Jul 2004 15:25:24 GMT  
 Problem with this excercise problem.

Quote:

> Hey, guys it is my first time posting.  I am having trouble with this
> problem for my computer science - scheme class.  (this site is our
> textbook online) http://www.htdp.org/2001-11-21/Book/node32.htm
> problem 6.6.3.  You must follow the first 2 problems to understand it.
> Exercise 6.6.3

> Use the template fun-for-circle to develop in-circle?. The function
> consumes a circle structure and a posn and determines whether or not
> the pixel is inside the circle. All pixels whose distance to the
> center is less or equal to the radius are inside the circle; the
> others are outside.

> Consider the circle in figure . The circle's center is (make-posn 6
> 2), its radius is 1. The pixel labeled A, located at (make-posn 6
> 1.5), is inside the circle. The pixel labeled B, located at (make-posn
> 8 6), is outside.

> Anyway, I know that I am supposed to find the distance of the point
> entered from the center of the circle.  I am not sure what to do. Here
> is what I have done so far.  The error I get is:
> illegal application: first term in application is a function-bound
> identifier.  Then it circle a-posn in (sqr (a-posn)))) at the bottom.

> ;; 6.6.1
> (start 300 300)
> ;; Data Definitions:
> (define-struct circle (center radius color))
> ;; Circle is a structure: (draw-a-circle ((make-posn 30 20) 50 'red):
> (make-posn 30 20) is a posn, 50 is anumber, 'red is a symbol.

> ;; Template:
> ;; (define (fun-for-circle a-circle)
> ;; ...(circle-center a-circle)...
> ;; ...(circle-radius a-circle)...
> ;; ...(circle-color a-circle)...)

> ;; 6.6.2
> ;; Contract: draw-a-circle: circle -> boolean
> ;; Purpose: consumes circle structure and draws the corresponding
> circle on the screen.
> (define (draw-a-circle a-circle)
>   (draw-circle (circle-center a-circle) (circle-radius a-circle)
> (circle-color a-circle)))

> ;; 6.6.3
> ;; Contract: in-circle?: circle posn -> boolean
> ;; Purpose: determine whether or not the pixel is inside the circle.
> (define (in-circle? a-circle a-posn)
>   (draw-circle (circle-center a-circle) (circle-radius a-circle)
> (circle-color a-circle)
>   (sqrt
>     (+ (sqr (circle-center a-circle))
>        (sqr (a-posn))))
>   (cond
>     [(<= a-posn (draw-a-circle (circle-radius))) 'inside-circle])))

> Can you keep in mind that I have only done up to that chapter in the
> book.  You can look on the site to see where I am.

Your time is probably best spent quietly reading the exercise. Though
from the looks of things quietly reading the first six chapters is
probably a much better idea in both the short and long term.

Quote:
>Use the template fun-for-circle to develop in-circle?.

You seem to almost have that, though you seem to be using
draw-a-circle instead of the template.

Quote:
>The function consumes a circle structure and a posn and determines
whether or
>not the pixel is inside the circle.

Ok, you seem to be using the correct inputs.

Quote:
>All pixels whose distance to the center is less or equal to the
radius are
> inside the circle; the others are outside.

Hmmn? distance? What if you had a distance function? What parameters
would it take? What would it return? What is the distance between two
points anyway? (This is probably the only question herein that you
would be likely to get answered with anything other than a question.)
Would the authors of HTDP think that writing a distance function would
be a good idea? Why or why not?  Is there some function that you
already have that might be useful for writing a distance function?

If you had a distance function, what would your function look like?



Sat, 03 Jul 2004 06:02:11 GMT  
 Problem with this excercise problem.

Quote:

> I am a student that is in high school.  My instructor says that you
> can get all the outside help you need, as long as you follow the book,

There's a nice geometric formula for distance in cartesian
coordinate systems.  It's

(sqrt(+ (sqr dx) (sqr dy)))

Where sqrt is a square root function, sqr is a square
function, dx is the difference between the x-coordinates of
the points you're measuring between, and dy is the difference
between the y-coordinates of the points you're measuring
between.  

From this formula, you should be able to derive your
(in-circle?) predicate.... In fact, from this formula,
some very smart people derived most of trigonometry, but
that is a tale for another day.

                                Bear



Sat, 10 Jul 2004 14:09:17 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Problems, problems, problems

2. Eiffel Problems, Problems, Problems

3. Excercises for Labview 5.0

4. Example in Excercise

5. Programming Excercise Needed

6. Ada Excercises

7. LISP - an excercise for experts?

8. Finn Idiom problems and Re: {rho} problem

9. Combinatorial Problem [ & a new Combinatorial Problem ]

10. Database problem/Memory problem??

11. CW 2003 - Focus problem & a select problem

12. 32bit problem - one problem solved & another found

 

 
Powered by phpBB® Forum Software