The problem is that i have drawn the transference curve and i have another line that's going to help me find the Q point the problem is that i need to know when the 2 lines meet. I have no idea on how to do this, the drawing is made on a picture box, with an image
public Bitmap GenerateGraph(int scale, int width, int height)
{
Bitmap image = new Bitmap(width, height);
int midX = width / 2;
int limY = height - 15;
Graphics g = Graphics.FromImage(image);
SolidBrush backgroundBrush = new SolidBrush(backgroundColor);
SolidBrush axisBrush = new SolidBrush(axisColor);
SolidBrush drawBrush = new SolidBrush(drawColor);
SolidBrush drawQ = new SolidBrush(qColor);
SolidBrush pointsBrush = new SolidBrush(pointsColor);
Pen qPen = new Pen(qColor);
Pen drawPen = new Pen(drawColor);
Pen axisPen = new Pen(axisColor);
Pen gridPen = new Pen(gridColor);
Pen curvePen = new Pen(curveColor);
Font axisFont = new Font(FontFamily.GenericSansSerif, axisFontSize);
Font pointsFont = new Font(FontFamily.GenericSansSerif, pointsFontSize);
//Limpiar Fondo
g.FillRectangle(backgroundBrush, 0, 0, width, height);
//Dibujar Lineas
if (drawAxes)
{
g.DrawLine(axisPen, 0, limY, width, limY);
g.DrawLine(axisPen, midX, 0, midX, limY);
//Dibujar Numeros
curnumber = 0;
float curX = midX;
while (curX < width)
{
if (curX != midX)
{
g.DrawLine(gridPen, curX, 0, curX, limY);
}
g.DrawLine(axisPen, curX, limY, curX, limY + 3);
g.DrawString(curnumber.ToString(), axisFont, axisBrush, curX - 3, limY + 5);
curX += scale;
curnumber++;
}
curnumber = 0;
curX = midX;
while (curX > 0)
{
if (curX != midX)
{
g.DrawLine(gridPen, curX, 0, curX, limY);
}
g.DrawLine(axisPen, curX, limY, curX, limY + 3);
g.DrawString(curnumber.ToString(), axisFont, axisBrush, curX - 3, limY + 5);
curX -= scale;
curnumber--;
}
curnumber = 1;
float curY = limY;
while (curY > 0)
{
if (curY != limY)
{
g.DrawLine(gridPen, 0, curY, width, curY);
}
g.DrawLine(axisPen, midX, curY, midX + 3, curY);
g.DrawString(curnumber.ToString(), axisFont, axisBrush, midX + 5, curY - (scale + 3));
curY -= scale;
curnumber++;
}
}
//Graficar Transferencia
double Vp;
double Idss;
double Id;
double Vgs;
float curXG = midX;
float curYG = limY;
//Polarizacion Fija
double showId;
double showVd;
double Vg;
double Vs = 0;
double Vds;
double Vgg;
double Vdd;
double Rd;
//Autopolarizacion
double aId;
double aVd;
double aVg;
double aVs;
double aVds;
double aVdd;
double aRd;
double aRs;
double aVgs;
double aVrs;
float p1;
float p2;
// double xAQ = Vp / 99;
PointF[] aPuntos = new PointF[2];
if (Double.TryParse(txtVp.Text, out Vp))
{
double x = Vp / 99;
if ((Double.TryParse(txtIdss.Text, out Idss)) && (Idss > 0))
{
if (Vp < 0)
{
Vgs = Vp;
txtTipo.Text = "N";
for (int i = 0; i < 100; i++)
{
Id = Idss * Math.Pow((1 - (Vgs / Vp)), 2);
IdPuntos[i] = new PointF((float)Vgs, (float)Id);
Id = Id * scale;
IdVgs[i] = new PointF((curXG + ((float)Vgs * scale)), (curYG - (float)Id));
Vgs = Vgs - x;
}
}
if (Vp > 0)
{
Vgs = Vp;
txtTipo.Text = "P";
for (int i = 0; i < 100; i++)
{
Id = Idss * Math.Pow((1 - (Vgs / Vp)), 2);
IdPuntos[i] = new PointF((float)Vgs, (float)Id);
Id = Id * scale;
IdVgs[i] = new PointF(curXG + ((float)Vgs * scale), curYG - (float)Id);
Vgs = Vgs - x;
}
}
}
else
{
MessageBox.Show("Solo se aceptan numeros mayores a 0 en Idss");
}
}
else
{
MessageBox.Show("Solo se aceptan numeros en Vp");
}
g.DrawCurve(curvePen, IdVgs);
for (int i = 0; i < 100; i += 22)
{
double xP = IdPuntos[i].X;
string sXP = String.Format("{0:0.00}", xP);
double yP = IdPuntos[i].Y;
string sYP = String.Format("{0:0.00}", yP);
string punto = "( " + sXP +", "+ sYP +" )";
g.DrawString(punto, pointsFont, pointsBrush, IdVgs[i]);
}
if (checkPolarizacionFija.Checked)
{
if (Double.TryParse(txtVp.Text, out Vp))
{
if ((Double.TryParse(txtIdss.Text, out Idss)) && (Idss > 0))
{
if (Double.TryParse(txtVgg.Text, out Vgg))
{
Vgs = (-Vgg);
Vg = (Vgs + Vs);
showId = Idss * Math.Pow((1 - (Vgs / Vp)), 2);
if (double.TryParse(txtVdd.Text, out Vdd))
{
if (double.TryParse(txtRd.Text, out Rd))
{
showVd = Vdd - (showId * Rd);
Vds = showVd;
txtId.Text = showId.ToString();
txtVd.Text = showVd.ToString();
txtVds.Text = Vds.ToString();
txtVg.Text = Vg.ToString();
txtVgs.Text = Vgs.ToString();
txtVs.Text = Vs.ToString();
string stringVgg = String.Format("{0:0.00}", (-Vgg));
string stringId = String.Format("{0:0.00}", showId);
txtQ.Text = "( " + stringVgg + ", " + stringId + " )";
g.DrawLine(qPen, new PointF((curXG + ((float)Vgs * scale)), curYG),
new PointF((curXG + ((float)(-Vgg) * scale)), (curYG - ((float)showId * scale))));
g.DrawString("Q = ( " + stringVgg + ", " + stringId + " )", pointsFont,
pointsBrush, new PointF((curXG + ((float)(-Vgg) * scale)), (curYG - ((float)showId * scale))));
}
else
{
MessageBox.Show("Solo se aceptan Numeros");
}
}
else
{
MessageBox.Show("Solo se aceptan Numeros");
}
}
else
{
MessageBox.Show("Solo se aceptan Numeros");
}
}
else
{
MessageBox.Show("Solo se aceptan Numeros");
}
}
}
if (checkAutopolarizacion.Checked)
{
//Primer punto
aPuntos[0] = new PointF(curXG, curYG);
//Segundo Punto
if (Double.TryParse(txtVp.Text, out Vp))
{
if ((Double.TryParse(txtIdss.Text, out Idss)) && (Idss > 0))
{
if (Double.TryParse(txtRs.Text, out aRs))
{
aId = Idss / 2;
aVgs = ((-Idss) * aRs) / 2;
aPuntos[1] = new PointF(curXG + ((float)aVgs * scale), curYG - ((float)aId) * scale);
g.DrawCurve(qPen,aPuntos);
}
}
}
//punto Q
//Calculos
}
return image;
}
this is what it looks like the pic, what i need help with is, how to know when they meet. In witch point they have the same coordinates.
Any help with this would be appreciated

New Topic/Question
Reply




MultiQuote



|