Program BMI - Random Point

Hey guys !

I’m new on the forum and I need help about my final project for exams.
I’ve made over 90% of the job and I need few help to finish this. Since 2/3 weeks I’m searching for a way but it continues to be wrong :confused:

So, when I execute my program, all is working like I want and a graphical window is appearing as normal when you can take a look to theoretical curves of the BMI.

On the first part, the user is questionned about his age, his weight and his size. He enters his answers then the windows is appearing perfectly.

Moreover, I’d like to create “the point of the user”, I mean, I’d like that a point appears according to his BMI and his age ; but I don’t find any way to do that

So I implore your help :weary:

Hope to get answers !
See ya !

PS : Sorry for my bad english, I’m from France and only seventeen years old :slight_smile:

1 Like

when age is a value on the x-axis (to the right)

and BMI on the y-axis (the higher the BMI the higher the point):

use map to say

float x = map(age,.....
float y = map(BMI, ....

ellipse(x,y,17,17);

Chrisir

It is in french but you might understand it as well.

The age must be between 10 and 18,

Moreover, I don’t know what to add after your “map”, I don’t know this function and I dont understand what they write on web :confused:

map is easy

float result (e.g. x) = map(
Input value (the age),
range start 1, range end 1,
range start 2, range end 2);

let’s say your age is between 10 and 18: that’s range 1.

And you want to show it on the window which is the range from 0 to width - that’s range 2:
Then map let’s you find the value you need on the 2nd range (x).

float x = map(age, 
10,18,
0,width);

map returns basically the percentage of the value (age) on the first range applied to the 2nd range.

Chrisir

1 Like

Hi,

You need to map the value of your data to a location in the screen.

You know that age is between 10 and 18.
Let’s say you want age 10 to be located at x = 10 and age 18 to be located at x = 90.

In that case you can find the position of every age using the map function as followed:
map(age, 10, 18, 10, 100);

Here an example:

int ageMin = 10;
int ageMax = 18;
int xMin = 10;
int xMax = 90;

void setup() {
  size(100, 40);
  background(20);
  
  int age = 16;
  noStroke();
  fill(200);
  float xPos = map(age, ageMin, ageMax, xMin, xMax);
  ellipse(xPos, 20, 5, 5);
}

Try playing around with the value of age to see how it behaves.

2 Likes

Well, I understand everything you said !

But I’ve got this…

You messed up the ellipse function. It should be x, y not y, 20 =)

1 Like

GOD DAMN IT !

Guys, you’re the best, I love you so much <3
It worked perfectly as I expected ! <3 <3 <3

Thanks so much !

I can’t know how to say thanks, I was looking for weeks and days !

2 Likes