4.05.2021

中文輸入法在pygame 2之後,有解了

 pygame2出了有一段時間了,最近才發現pygame2解決了windows下中文輸入法,

原本要自己實作的大問題,

基本上是利用start_text_input()等相關function來實作,參:https://www.pygame.org/docs/ref/key.html#pygame.key.start_text_input

詳細實作的程式碼,請參考以下URL:

https://github.com/pygame/pygame/blob/main/examples/textinput.py


8.15.2020

What is the difference between namespace dot namespace and nested namespace?(轉貼)

For C# Namespace: 

Is there any difference between:

namespace Outer.Inner
{
}

And

namespace Outer
{
    namespace Inner
    {
    }
}

in C#?


No difference whatsoever, those are the same thing, however the first one is more common.

8.02.2020

Python f string and r string

What is the best way to represent a Windows directory, for example "C:\meshes\as"?
you can use always:
'C:/mydir'
this works both in linux and windows. Other posibility is
'C:\\mydir'
if you have problems with some names you can also try raw string literals:
r'C:\mydir'
(在C#中,如針對Path, 可用@"path")
2. f string (Ref:medium.com)
可用 f-string 改成如下格式(在C#, 請用$"string{variable}"),就可以將之前的變量帶入並格式化輸出喔!:
f"I am {first_name} {middle_name}. {last_name}"

9.21.2019

最近看的影集及電影(雷)

這幾天,因為網友推薦,看了關於我轉生變成史萊姆這檔事
看完第一季,覺得還不錯,只是推薦我看的網友,知道史萊姆是什麼,
但是居然沒有聽過勇者鬥惡龍這個遊戲。
我和網友都懷疑,主角會不會變成最後大魔王,要跟勇者對決?

今天,為了消秏MOD的看片金,看了 詐騙女神 這部片,
覺得還OK, 好在最後的走向我有喜歡,如果變成純愛劇,
我會覺得很爛…

7.05.2019

0/0未定義的原因 (小學數學)

0/0是未定義,那為何0/0不是1呢?是否有反例?
我想到的反例如下:(這是我自己想的,如有錯誤,還請指正)
Assume 0/0 = 1,
if 2x = 3x
=> x = 1.5x, so x = 0
=> 0 = 1.5 * 0
兩邊同除0
=> 0/0 =1.5 * 0/0
=> (0/0) = 1.5 * (0/0)
We assume 0/0 = 1
=> 1 = 1.5 * 1
=> 1 = 1.5, 所以這是0/0 = 1的反例

那麼0/0是否等於0呢?
這個我不知道真正的反例,
但是這樣0/0就不能上下消去得到1了。
至於0/0等於其它數值,可以簡單得到反例,
這就不提了。



6.13.2019

Differential and Partial differential


Differential of a function

dy=f'(x)\,dx,
where  is the derivative of f with respect to x, and dx is an additional real variable (so that dy is a function of x and dx). The notation is such that the equation
holds, where the derivative is represented in the Leibniz notation dy/dx, and this is consistent with regarding the derivative as the quotient of the differentials. One also writes


satisfies
where the error ε in the approximation satisfies ε/Δx → 0 as Δx → 0. In other words, one has the approximate identity
in which the error can be made as small as desired relative to Δx by constraining Δx to be sufficiently small; that is to say,
as Δx → 0. For this reason, the differential of a function is known as the principal (linear) part in the increment of a function: the differential is a linear function of the increment Δx, and although the error ε may be nonlinear, it tends to zero rapidly as Δx tends to zero.

the partial differential of y with respect to any one of the variables x1 is the principal part of the change in y resulting from a change dx1 in that one variable. The partial differential is therefore

參:
https://en.wikipedia.org/wiki/Differential_of_a_function


全微分和偏微分有什麼不同
假設 z = x^7 + y^3 + 3(x^2)*(y^4) + 4xy + 98 
z為應變數 , x y為自變數 

全微分 : 
就是所有變數通通都要微分 
dz = 7x^6dx + 3y^2dy + 6x(y^4)dx + 12(x^2)*(y^3)dy + 4ydx + 4xdy + 0 
ps. 兩變數相乘的 , 如同一般乘法的微分 , 前微後不微+前不微後微 

偏微分 : 
只對要微的自變數微分 , 其他的都當作常數 
1.對 x 偏微 
∂z/∂x = 7x^6 + 0 + 6x(y^4) + 4y + 0 

2. 對 y 偏微 
∂z/∂y = 0 + 3y^2 + 12(x^2)*(y^3) + 4x + 0

參:
https://tw.answers.yahoo.com/question/index?qid=20050930000013KK04937