Scaling log values form log 0 to log 1 to scale log 0 to log 1.41.

anneranch

New member
Joined
Mar 27, 2020
Messages
14
I am constructing / drawing Smith chart using OpenGL (C programming language )
I am using normalized scale circles with diameter from 0 to 1.
I can draw 10 of these circles in log(10) scale - from 0 to 1 - in .1 intervals - no problem.
Now I need draw 10 of these circles , BUT they have to be scaled to fit into linear area from 0 to 1.41,
So in layman's terms - how do I scale log(0) - log(1) to log(0) - log(1.41) and maintain logarithmic scale?
I did try
double mark = -(log(index ));
mark *= 1.41;
but it "linearized / destroyed ' the overall logarithmic scale of the circles and did not fill 0 to 1.41 linear scale. .
I need to scale each circle and have them in logarithmic succession in same ratio as log 0 to log 1.

PS OpenGL /C handles the log(0) just fine.
 
Last edited by a moderator:
Sorry for the "bump" .
Also I cannot figure out how to edit the original post to make it more descriptive.

I made some progress with my design but I am still stomped by this task.
Per original post , I am constructing Smith chart using C/C++ and OpenGL.
From (limited ) construction notes - the chart has two basic parts
"real" axis circles and "imaginary " axis circles.
I have the base real axis circle done , mathematically.
Then I use OpenGL to do its magic to construct part (>1 ) of both positive and negative "axis" circles.
What I am missing is the < 1 imnaginary part circles.
In the attached file - these are the circles partially draw with red color.
The red part was done using OpenGL and obviously it is wrong / incomplete.

I need real help figuring out the mathematical solution.
In laymen terms -
draw (min 10) circles with centers on Y axis -
first one with (normalized) radius of 1 and "touching" both X and Y axis and centered @ X = 1 and Y=1.
then draw circles centered on X= 1 and Y= unknown radius , increasing the radius until
last one with so far unknown radius, centered @X = 1 and Y = unknown radius, touching X axis.

The "last " circle being of mathematical value = 0 and for all practical purpose having radius of infinity.
But software takes care of such infinity nicely, that is no [problem.

The problem is HOW to calculate the changing radius to draw minimum of 10 circles.

I will be grateful for any hints how to solve this, preferably mathematically.

Thanks

PS There is Screenshot from 2020-04-15 12-02-22.png (my) bug in code, that is why it "skips" some circles.



 
I am constructing / drawing Smith chart using OpenGL (C programming language )
I am using normalized scale circles with diameter from 0 to 1.
I can draw 10 of these circles in log(10) scale - from 0 to 1 - in .1 intervals - no problem.
Now I need draw 10 of these circles , BUT they have to be scaled to fit into linear area from 0 to 1.41,
So in layman's terms - how do I scale log(0) - log(1) to log(0) - log(1.41) and maintain logarithmic scale?
I did try
double mark = -(log(index ));
mark *= 1.41;
but it "linearized / destroyed ' the overall logarithmic scale of the circles and did not fill 0 to 1.41 linear scale. .
I need to scale each circle and have them in logarithmic succession in same ratio as log 0 to log 1.
PS OpenGL /C handles the log(0) just fine.
You said:

"I need to scale each circle and have them in logarithmic succession in same ratio as log 0 to log 1."

The problem is

log(0) is UNDEFINED

and

log(1) = 0

The ratio you want does not exist.
 
You said:

"I need to scale each circle and have them in logarithmic succession in same ratio as log 0 to log 1."

The problem is

log(0) is UNDEFINED

and

log(1) = 0

The ratio you want does not exist.
Sorry, but log(0) is NOT the issue , the software takse care of that.
Actually the original pos is no longer valid , but I have no found the way to either change the title or delete it.
 
It looks as drawing circles starting with diameter 1 , actual value same, and ending with diameter 1000 , approximate value of 0 would work.
Now all I need is to figure out the actual diameters - scale - showing approximate increase of value in .1 steps.
Any "linear" apprach does not work - it has to be non-linear scale.
Something to matich the appearnce of "real" axis , which is not as originaly thought in logarithmic scale but in 1/R+1 scale.
 
PS OpenGL /C handles the log(0) just fine.

You're probably just not checking for these errors, which you could do like this...

C:
#include <math.h>
#include <errno.h>
#include <stdio.h>

void calcLog(double x) {
  double a;
  printf("\nAbout to calculate log(%f)...\n", x);
  a=log(x);
  printf("got %f\n", a);
  if (errno!=0) printf("An error occurred!!!\n");
}

int main() {
  errno=0; /* initialise errno */

  calcLog(3);
  calcLog(0);
  
  return 0;
}

Expected output:-

About to calculate log(3.000000)...
got 1.098612

About to calculate log(0.000000)...
got -inf
An error occurred!!!

...but it's generally better/ easier to write code that can't generate floating point errors by avoiding log(0) etc
 
You're probably just not checking for these errors, which you could do like this...

C:
#include <math.h>
#include <errno.h>
#include <stdio.h>

void calcLog(double x) {
  double a;
  printf("\nAbout to calculate log(%f)...\n", x);
  a=log(x);
  printf("got %f\n", a);
  if (errno!=0) printf("An error occurred!!!\n");
}

int main() {
  errno=0; /* initialise errno */

  calcLog(3);
  calcLog(0);
 
  return 0;
}

Expected output:-

About to calculate log(3.000000)...
got 1.098612

About to calculate log(0.000000)...
got -inf
An error occurred!!!

...but it's generally better/ easier to write code that can't generate floating point errors by avoiding log(0) etc

PLEASE
could you PLEASE reread the SECOND post !
I do not feel happy about recent posters wasting their time on NON ISSUE.
These are replies to something I am not concerned about .
Please , no more log(0) commentaries.
Do not waste YOUR time on non issue !

PLEASE
could you PLEASE reread the SECOND post !
I do not feel happy about recent posters wasting their time on NON ISSUE.
These are replies to something I am not concerned about .
Please , no more log(0) commentaries.
Do not waste YOUR time on non issue !
 
I think it may be best if you start a new thread with the question you really want answered, to avoid confusion. Tell us exactly what you want to do (don't just copy post #2) as if we've never seen this thread. Perhaps focus on the math, defining the circles you want to draw, without assuming anyone knows what a Smith chart or OpenGL is. And don't say things like "circle being of mathematical value = 0", which doesn't mean anything.

We need to start fresh.
 
I think it may be best if you start a new thread with the question you really want answered, to avoid confusion. Tell us exactly what you want to do (don't just copy post #2) as if we've never seen this thread. Perhaps focus on the math, defining the circles you want to draw, without assuming anyone knows what a Smith chart or OpenGL is. And don't say things like "circle being of mathematical value = 0", which doesn't mean anything.

We need to start fresh.
Thanks for your opinion.
Here is mine
I have explained the issue to the best of mine abilities.
It looks as there is a mismatch between this forum abilities / interests and the issue.
Rewording or starting anew is just pointless, in my opinion.
I prefer not to get an answer instead of beautifying the OP for folks who
cannot read or analyze.
Perhaps this thread shoud be closed / deleted etc.
Cheers
 
Last edited by a moderator:
Top