Algorithmic Scaling

Discussion in 'C++' started by caged_fire, Aug 28, 2010.

  1. caged_fire

    caged_fire New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    So, I have been working on some code with a group of people/organisations etc. and I've hit a small bump in the road that I thought someone on here may be able to help me with :)
    I have developed some code that draws 3D towers to represent the amount energy particular objects have, thus creating a sort of graph. I am currently using a very basic linear scaling algorithm but I wish to use a logarithmic method of scaling.

    Currently my algorithm does the following:
    NB: I only scale in x, y as z is the height and represents a completely different thing.

    1: Calculates the centre point of the object
    2: Calculates the distance between the centre and each corner
    3: Divides this by the data collections maximum/highest energy
    4: Multiplies this by the current objects energy
    5: Adds this final value to the centre point

    e.g.
    corners.x = centre[0] + ( ( ( corners.x - centre[0] ) / max ) * energy );
    corners.y = centre[1] + ( ( ( corners.y - centre[1] ) / max ) * energy );
    In effect this scales the objects in proportion to the maximum recorded energy for a given data collection (a sort of percentage).
    I wish to use a logarithmic scaling method to do the same thing but I am not sure how I would do this.
    I am not all that great when it comes to Maths but particularly when it comes to logarithmic scaling in C++.....I would appreciate if someone could give me a hand with this. In particular coding examples in C++ would be very useful

    Thanks in advance
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice