Op mijn werk heb ik een klein excel sheetje van mijn voorganger overgenomen, met daarin een macro die een bepaalde score berekent gegeven 2 punten en een constante. De code heeft geen bruikbare comments dus ik weet niet wat m'n voorganger heeft gedaan.
De code begrijp ik wel, alleen ik heb wat hulp nodig bij de berekeningen die gedaan worden, het punt wat ik niet begrijp is hoe v & w worden uitgerekend. Mijn meetkunde is danig weggezakt
Zou iemand me deze score funcite kunnen uitleggen?
Bedankt!
De code begrijp ik wel, alleen ik heb wat hulp nodig bij de berekeningen die gedaan worden, het punt wat ik niet begrijp is hoe v & w worden uitgerekend. Mijn meetkunde is danig weggezakt
Bedankt!
Visual Basic:
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
60
61
62
| Function Score(x As Double, y As Double, a As Double) As Double Dim w As Double Dim v As Double Dim r As Double Dim phi As Double Dim R_0 As Double Dim C As Double Dim w_threshold As Double Dim v_threshold As Double r = length(x, y) phi = angle(x, y) w = r * Cos(phi) v = r * Sin(-phi) 'Determine threshold: (v_threshold, w_threshold) 'R_0 = w - a * (v ^ 2) v_threshold = 1 / (2 * a) 'If independent variable "v" is beyond threshold "v_treshold" then use alternate score-value If v > v_threshold Then w_threshold = (w - v) + v_threshold Score = Metric(v_threshold, w_threshold, a) ElseIf v < (-v_threshold) Then w_threshold = (w + v) + v_threshold Score = Metric(v_threshold, w_threshold, a) Else Score = Metric(v, w, a) End If End Function Function Metric(v As Double, w As Double, a As Double) As Double 'R_0 = w - a * (v ^ 2) 'C = ScoreValue(R_0) 'Metric = w - a * (v ^ 2) - R_0 + C Metric = w - a * (v ^ 2) Debug.Print "score: " & Metric End Function Function angle(x As Double, y As Double) As Double Dim offset As Double offset = WorksheetFunction.Radians(45) angle = WorksheetFunction.Atan2(x, y) - offset End Function Function length(x As Double, y As Double) As Double length = Sqr(x ^ 2 + y ^ 2) End Function |