![]() |
Mathematiknachhilfe...
Hallo alle...
irgendwie ist heute meine mathematische Gehirnzelle noch nicht wach... :oops: Ich will einer Funktion einen Prozentwert (Integer) übergeben und den entsprechenden Integerwert zurückbekommen. Hört sich leicht an... aber: Wert 255 entspricht 0% Wert 128 entspricht 100% bedeutet 50% = 192 Danke für´s Helfen... PS: umgekehrt (Wert in Prozent) geht so: 100 - ((aValue - 127) * 100) div 127 |
AW: Mathematiknachhilfe...
128*x+255*(1-x), wobei x ein Wert zwischen 0 und 1 ist.
|
AW: Mathematiknachhilfe...
Hi,
die Zahlen sind etwas krumm ;) Kann es sein, dass 127 die 100% sein sollen? Dann wäre es so: 255 - (128 / 100 * Eingabe) LG, Frederic |
AW: Mathematiknachhilfe...
127+128*(x/100). x von 0 bis 100 %.
EDIT: Erste 128 durch 127 geändert. |
AW: Mathematiknachhilfe...
Delphi-Quellcode:
Danach sind die 50% allerdings 191, siehe Frederic.
function KomischerProzentwert(Prozent: integer): integer;
const VALMAX = 255; VALMIN = 128; OFFSET = VALMAX - VALMIN; var PrzVal: integer; begin PrzVal := Round(OFFSET / 100 * Prozent); Result := VALMAX - PrzVal; end; |
AW: Mathematiknachhilfe...
Zum Verständnis:
Hex 00 - 7F = 0 - 127 -> 00 = 0% , 7F = 100% Hex 80 - FF = 128 - 255 -> 80 = 100% , FF = 0% Bitte gebt mir für´s testen noch einen Moment. Ich muß noch eine Kleinigkeit vorher fertig machen, damit sich der Quark kompillieren läßt...8-) |
AW: Mathematiknachhilfe...
Anfangswert + (Endwert-Anfangswert) * ProzentuellerWert/100
Anfangswert = 255 Endwert = 128 ProzentuellerWert = 50 255 + (128-255) * 50/100 = 255 - 127 * 0.5 = 255 - 64 ~ 191 |
AW: Mathematiknachhilfe...
Geradlinige Interpolation: y(x):= y1 + (y2-y1) / (x2-x1) * (x-x1)
ggf. y:= Round (...) |
AW: Mathematiknachhilfe...
Ich hätt da auch noch eine...
Delphi-Quellcode:
{ lineare Interpolation }
function interpol(tabwert, tab1, tab2, ergebnis1, ergebnis2: Double): Double; begin Result := (((tabwert - tab1) / (tab2 - tab1)) * (ergebnis2 - ergebnis1)) + ergebnis1; end; |
AW: Mathematiknachhilfe...
Danke an alle...
so paßt´s: 255 - Round((127 * (aPercent / 100))) ... und 50% ist 191... ihr habt ja Recht :zwinker: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:07 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz