python求方程解析解

解一元方程:

1
2
3
from sympy import *
x, a, b, c = symbols('x a b c')
solve(a * x**2 + b * x + c, x)

解二元方程:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from sympy import *
x, y, z = symbols('x y z')
solve([y + x - 1, 3 * x + 2 * y - 5], [x, y])
limit(sin(x) / x, x, 0)
simplify(sin(x)**2 + cos(x)**2)
expand((x + 1)**2)
factor(x**2 + 2*x + 1)
collect(x*y + x - 3 + 2*x**2 - z*x**2 + x**3, x)
trigsimp(cosh(x)**2 + sinh(x)**2)
expand_trig(sin(x + y)) 
 
x, y = symbols('x y', positive=True)
n = symbols('n', real=True)
expand_log(log(x*y))
logcombine(n*log(x))
 
E**(I*pi)+1
expand(exp(I*x), complex=True)
 
tmp = series(exp(I*x), x, 0, 10)
pprint(tmp)
re(tmp)
series(sinh(x), x, 0, 10)
 
integrate(x*sin(x), x)
integrate(x*sin(x), (x, 0, 2*pi))
diff(x**2)
 
r = symbols('r', positive=True)
circle_area = 2 * integrate(sqrt(r**2-x**2), (x, -r, r))
circle_area.subs(r, x)

refer to: https://blog.csdn.net/shuangguo121/article/details/86611948

https://www.cnblogs.com/coshaho/p/9653460.html
https://baike.baidu.com/item/%E5%8F%8C%E6%9B%B2%E5%87%BD%E6%95%B0/8704306?fr=aladdin

C#文件复制到剪切板

1
2
3
4
5
6
7
8
9
10
11
void CopyToClipboard(string[] files, bool cut)
{
	if (files == null) return;
 
	IDataObject data = new DataObject(DataFormats.FileDrop, files);
	MemoryStream memo = new MemoryStream(4);
	byte[] bytes = new byte[] { (byte)(cut ? 2 : 5), 0, 0, 0 };
	memo.Write(bytes, 0, bytes.Length);
	data.SetData("Preferred DropEffect", memo);
	Clipboard.SetDataObject(data);
}

参考自:https://www.codeproject.com/kb/shell/explorer_drag_drop.aspx

C#鼠标拖动图片控件中的图片

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
private Image capturedImage = null;
private Point capturedImageLocation;
private Point capturedImageCursorLocation;
private bool capturedImageIsMouseDown = false;
private bool capturedImageIsFullDisplayed = false;
private void dataGridViewRecord_CellClick(object sender, DataGridViewCellEventArgs e)
{
	string str = dataGridViewRecord.Rows[e.RowIndex].Cells["pic1"].Value.ToString();
	capturedImage = System.Drawing.Image.FromFile(str);
	capturedImageLocation = new Point(0, 0);
	pictureBoxCaptured.Invalidate();
}
 
 
private void pictureBoxCaptured_DoubleClick(object sender, EventArgs e)
{
	if (capturedImageIsFullDisplayed)
		capturedImageIsFullDisplayed = false;
	else
		capturedImageIsFullDisplayed = true;
	pictureBoxCaptured.Invalidate();
}
private void pictureBoxCaptured_MouseDown(object sender, MouseEventArgs e)
{
	if (capturedImageIsFullDisplayed)
		return;
 
	capturedImageIsMouseDown = true;
	capturedImageCursorLocation = new Point(e.X - capturedImageLocation.X, e.Y - capturedImageLocation.Y);
}
private void pictureBoxCaptured_MouseUp(object sender, MouseEventArgs e)
{
	capturedImageIsMouseDown = false;
}
private void pictureBoxCaptured_MouseMove(object sender, MouseEventArgs e)
{
	if (capturedImageIsFullDisplayed)
		return;
	if (!capturedImageIsMouseDown)
		return;
	capturedImageLocation = new Point(e.X - capturedImageCursorLocation.X, e.Y - capturedImageCursorLocation.Y);
	pictureBoxCaptured.Invalidate();
}
private void pictureBoxCaptured_Paint(object sender, PaintEventArgs e)
{
	if (null == capturedImage)
		return;
 
	if (capturedImageIsFullDisplayed)
	{
		e.Graphics.DrawImage(capturedImage, pictureBoxCaptured.ClientRectangle, //e.ClipRectangle,
			new Rectangle(0, 0, capturedImage.Width, capturedImage.Height), GraphicsUnit.Pixel);
	}
	else
	{
		e.Graphics.DrawImage(capturedImage, pictureBoxCaptured.ClientRectangle,
			new Rectangle(-capturedImageLocation.X, -capturedImageLocation.Y, pictureBoxCaptured.Width, pictureBoxCaptured.Height), GraphicsUnit.Pixel);
	}
}

C#子线程让主窗体执行代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public delegate void OutDelegate(ParseXmlResult xmlResult);
public void insertDataGridView(ParseXmlResult xmlResult)
{
	if (dataGridViewRecord.InvokeRequired)
	{
		OutDelegate outdelegate = new OutDelegate(insertDataGridView);
		this.BeginInvoke(outdelegate, new object[] { xmlResult });
		return;
	}
 
	DateTime date;
	string[] format = { "yyyyMMddHHmmss" };
	DateTime.TryParseExact(xmlResult.time.Substring(0, 14),
		format,
		System.Globalization.CultureInfo.InvariantCulture,
		System.Globalization.DateTimeStyles.None,
		out date);
 
	dataGridViewRecord.Rows.Add(new object[] { dataGridViewRecord.Rows.Count + 1, date.ToString("yyyy-MM-dd HH:mm:ss"), xmlResult.plate, xmlResult.files[0] });
}
private Thread workThread;
private void ProcessWork()
{
	insertDataGridView(xmlResult);
}
private static void ProcessThread(object param)
{
	MainForm pThis = param as MainForm;
	pThis.ProcessWork();
}
private void btnSearch_Click(object sender, EventArgs e)
{
	workThread = new Thread(new ParameterizedThreadStart(ProcessThread));
	workThread.Start(this);
}

yuv IplImage

1
2
3
4
5
6
7
8
9
10
IplImage *Yuv2IplImage(char *yuv, int imgWidth, int imgHeight)
{
	cv::Mat matYUV(imgHeight * 3 / 2, imgWidth, CV_8UC1, yuv);
	cv::Mat matBGR;
	cv::cvtColor(matYUV, matBGR, cv::COLOR_YUV2BGR_NV12);
 
	IplImage imgTmp = matBGR;
	IplImage *img = cvCloneImage(&imgTmp);
	return img;
}

火狐控件弹出菜单后没反应

如果能改控件程序,比如用FireBreath做的控件,就要使onWindowEvent函数中的WM_PAINT和WM_ERASEBKGND重载返回false。

如果不能改控件程序,试试卸载firefox,再删除文件夹C:\Users\用户名\AppData\Roaming\Mozilla\Firefox,最后重装firefox。同时记住关掉firefox的自动更新。

但有可能重装了也不行,任务管理器中还是两个firefox.exe进程,子进程的命令行参数为:

"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -contentproc --channel="7924.0.1582778285\845967500" -greomni "C:\Program Files (x86)\Mozilla Firefox\omni.ja" -appomni "C:\Program Files (x86)\Mozilla Firefox\browser\omni.ja" -appdir "C:\Program Files (x86)\Mozilla Firefox\browser" ?7924 "\\.\pipe\gecko-crash-server-pipe.7924" tab

所以能改控件程序最完美。