post  New Function

fleur1990 (5)   Link to this post
Hello Hello!

can you explain me what this function does line by line please

Polyline drawFunction(const vector<double>& inValues,
double inScaleX, double inScaleY)
{
Polyline lLine;
for(int i = 0; i < inValues.size(); ++i) {
lLine += Point(i*inScaleX, inValues[i]*inScaleY);
}
return lLine;
}

thank you very much
screw (126)   Link to this post
Welcome here!

It is rewarding to use the source code tag from format notation.

Like this:
1
2
3
4
5
6
7
8
9
Polyline drawFunction(const vector<double>& inValues,
double inScaleX, double inScaleY)
{
  Polyline lLine;
  for(int i = 0; i < inValues.size(); ++i) {
    lLine += Point(i*inScaleX, inValues[i]*inScaleY);
  }
return lLine;
}


Ok, this is a function. Here is a description about functions:

http://www.codersource.net/c++_tutorial_functions.html

(But you can find more info of course.)

This drawFunction return a Polyline type value. You didn' write down what is it. It is possible that is a class.

drawFunction has some argument: const vector<double>& inValues is a container. You can store many object in this container. Some info about vector:

http://www.cplusplus.com/reference/stl/vector/
http://www.cplusplus.com/reference/stl/vector/push_back/

double inScaleX, double inScaleY arguments allow us that the points can be scaled with these values. (I think.)

4. line: iLine object is created.
5. line: It is a statement, called for. Some info:

http://www.hitmill.com/programming/cpp/forLoop.htm

Here all double type value are evaluated from vector (look at the size method of vector) and iLine object is added with some values. I don't know the Point class.

At least iLine object is returned in the 8.line.
kbw (1497)   Link to this post
The point of the class is pretty obvious. Is this your homework?
writetonsharma (832)   Link to this post
It is trying to draw a 3D sphere with lighting and shadows.
Last edited on
fleur1990 (5)   Link to this post
thank you every body it answers to my questions :)

This topic is archived - New replies not allowed.