PVector limit function

Hey everyone,

I have a very simpel question, but I seriues don't know the right answer. It would be wonder if some can help me.

I am reading the nature of code book. and I want to make exercise 1.4

The exercise look like this:

Write the limit() function for the PVector class.

void limit(float max){
  if (....... > ......)
  {
   ........... (); 
   ............... (max);
  }
}

please do someone knows what must stand on the do pionts? thanks so much :)

Answers

  • What is this limit() function supposed to do?

  • Answer ✓

    hi! you can always check processing PVector class source to get the answer link

    here is the code:

    void limit(float max) { if (magSq() > max*max) { normalize(); mult(max); } }

  • I know this discussion is over a month old, but you just posted a full code solution to an obvious homework problem.

    Are you trying to get banned, @rackatansky?

  • sorry i didn't know it's a homework!

  • edited May 2015

    @rackatansky, you simply linked to Processing's own source code. Nothing wrong w/ that!
    Besides, administrator's general forum rules are announced at the top & described here: http://forum.processing.org/two/discussion/8042/processing-forum-rules-and-advices
    Unless something very unacceptable, anything beyond that is extra judicial and abuse of moderator's authority! [-(

  • Apologies! Never wanted to abuse anyone, just trying to help. Cheers.

  • I can't see it's a homework either.

    Maybe he's just working through the book...?

    Let's not get dogmatic here...

    ;-)

  • @rackatansky, I said you did nothing against official forum rules!
    You've got nothing to excuse or feel sorry about! ;;)

  • Thanks everyone, Sorry for my late reaction. Bizzy with school, I am sure you all know that.

    Hihi it was not a homework thing. I was only me trying to go through the nature of code book. hihi Thanks so much for the answer.

Sign In or Register to comment.