Commit 67e1aa3a authored by Over_score's avatar Over_score

Fix -0 in trig calculation and fix r theta labeling

parent d71d7220
......@@ -47,7 +47,7 @@ void fnCxToRe(uint16_t unusedParamButMandatory) {
real16RectangularToPolar(REGISTER_REAL16_DATA(REGISTER_L), REGISTER_IMAG16_DATA(REGISTER_L), REGISTER_REAL16_DATA(REGISTER_Y), REGISTER_REAL16_DATA(REGISTER_X)); // X in radians
convertAngle16FromTo(REGISTER_REAL16_DATA(REGISTER_X), AM_RADIAN, currentAngularMode);
setRegisterAngularMode(REGISTER_X, currentAngularMode);
temporaryInformation = TI_RADIUS_THETA;
temporaryInformation = TI_THETA_RADIUS;
}
refreshStack();
......@@ -71,7 +71,7 @@ void fnCxToRe(uint16_t unusedParamButMandatory) {
real34RectangularToPolar(REGISTER_REAL34_DATA(REGISTER_L), REGISTER_IMAG34_DATA(REGISTER_L), REGISTER_REAL34_DATA(REGISTER_Y), REGISTER_REAL34_DATA(REGISTER_X)); // X in radians
convertAngle34FromTo(REGISTER_REAL34_DATA(REGISTER_X), AM_RADIAN, currentAngularMode);
setRegisterAngularMode(REGISTER_X, currentAngularMode);
temporaryInformation = TI_RADIUS_THETA;
temporaryInformation = TI_THETA_RADIUS;
}
refreshStack();
......
......@@ -33,7 +33,7 @@ void fnReToCx(uint16_t unusedParamButMandatory) {
uint32_t dataTypeY = getRegisterDataType(REGISTER_Y);
bool_t xIsAReal;
if( (dataTypeX == dtReal16 || dataTypeX == dtReal34 || dataTypeX == dtLongInteger)
if( (dataTypeX == dtReal16 || dataTypeX == dtReal34 || dataTypeX == dtLongInteger)
&& (dataTypeY == dtReal16 || dataTypeY == dtReal34 || dataTypeY == dtLongInteger)) {
copySourceRegisterToDestRegister(REGISTER_X, REGISTER_L);
......
......@@ -106,7 +106,7 @@ void WP34S_Cvt2RadSinCosTan(const realIc_t *an, uint32_t angularMode, realIc_t *
}
else { // angle < 90
if(realIcCompareGreaterThan(&angle, angle45 + angularMode)) { // angle > 45°
realIcSubtract(angle90 + angularMode, &angle, &angle); // 90° - angle --> angle
realIcSubtract(angle90 + angularMode, &angle, &angle); // 90° - angle --> angle
swap = !swap;
}
......@@ -120,9 +120,7 @@ void WP34S_Cvt2RadSinCosTan(const realIc_t *an, uint32_t angularMode, realIc_t *
if(tan != NULL) realIcSetNegativeSign(tan);
}
if(realIcIsZero(sin)) {
if(!getFlag(FLAG_DANGER)) {
realIcSetPositiveSign(sin);
}
realIcSetPositiveSign(sin);
if(tan != NULL) {
realIcSetPositiveSign(tan);
}
......@@ -134,10 +132,14 @@ void WP34S_Cvt2RadSinCosTan(const realIc_t *an, uint32_t angularMode, realIc_t *
realIcSetNegativeSign(cos);
if(tan != NULL) realIcChangeSign(tan);
}
if(realIcIsZero(cos) && !getFlag(FLAG_DANGER)) {
if(realIcIsZero(cos)) {
realIcSetPositiveSign(cos);
}
}
if(tan != NULL && realIcIsZero(cos)) {
realIcSetPositiveSign(tan);
}
}
......@@ -197,14 +199,20 @@ void WP34S_SinCosTanTaylor(const realIc_t *a, bool_t swap, realIc_t *sinOut, rea
}
}
if(realIcIsZero(&cos)) {
realIcSetPositiveSign(&cos);
}
if(realIcIsZero(&sin)) {
realIcSetPositiveSign(&sin);
}
if(sinOut != NULL) {
real51Multiply(&sin, &angle, &sin);
//realIcCopy(&sin, sinOut);
realIcAdd(&sin, const_0, sinOut);
}
if(cosOut != NULL) {
//realIcCopy(&cos, cosOut);
realIcAdd(&cos, const_0, cosOut);
}
......
......@@ -1123,6 +1123,26 @@ void refreshRegisterLine(calcRegister_t regist) {
showString(tmpStr3000, &numericFont, SCREEN_WIDTH - w, Y_POSITION_OF_REGISTER_X_LINE - REGISTER_LINE_HEIGHT*(regist - REGISTER_X), vmNormal, false, true);
}
else if(temporaryInformation == TI_THETA_RADIUS) {
if(regist == REGISTER_X) {
strcpy(prefix, STD_theta STD_SPACE_FIGURE "=");
prefixWidth = stringWidth(prefix, &standardFont, true, true) + 1;
}
if(regist == REGISTER_Y) {
strcpy(prefix, "r" STD_SPACE_FIGURE "=");
prefixWidth = stringWidth(prefix, &standardFont, true, true) + 1;
}
real16ToDisplayString(REGISTER_REAL16_DATA(regist), getRegisterAngularMode(regist), tmpStr3000, &numericFont, SCREEN_WIDTH - prefixWidth);
w = stringWidth(tmpStr3000, &numericFont, false, true);
lineWidth = w;
if(prefixWidth > 0) {
showString(prefix, &standardFont, 1, Y_POSITION_OF_REGISTER_X_LINE + TEMPORARY_INFO_OFFSET - REGISTER_LINE_HEIGHT*(regist - REGISTER_X), vmNormal, true, true);
}
showString(tmpStr3000, &numericFont, SCREEN_WIDTH - w, Y_POSITION_OF_REGISTER_X_LINE - REGISTER_LINE_HEIGHT*(regist - REGISTER_X), vmNormal, false, true);
}
else if(temporaryInformation == TI_X_Y) {
if(regist == REGISTER_X) {
strcpy(prefix, "x" STD_SPACE_FIGURE "=");
......@@ -1186,6 +1206,26 @@ void refreshRegisterLine(calcRegister_t regist) {
showString(tmpStr3000, &numericFont, SCREEN_WIDTH - w, Y_POSITION_OF_REGISTER_X_LINE - REGISTER_LINE_HEIGHT*(regist - REGISTER_X), vmNormal, false, true);
}
else if(temporaryInformation == TI_RADIUS_THETA) {
if(regist == REGISTER_X) {
strcpy(prefix, STD_theta STD_SPACE_FIGURE "=");
prefixWidth = stringWidth(prefix, &standardFont, true, true) + 1;
}
if(regist == REGISTER_Y) {
strcpy(prefix, "r" STD_SPACE_FIGURE "=");
prefixWidth = stringWidth(prefix, &standardFont, true, true) + 1;
}
real34ToDisplayString(REGISTER_REAL34_DATA(regist), getRegisterAngularMode(regist), tmpStr3000, &numericFont, SCREEN_WIDTH - prefixWidth);
w = stringWidth(tmpStr3000, &numericFont, false, true);
lineWidth = w;
if(prefixWidth > 0) {
showString(prefix, &standardFont, 1, Y_POSITION_OF_REGISTER_X_LINE + TEMPORARY_INFO_OFFSET - REGISTER_LINE_HEIGHT*(regist - REGISTER_X), vmNormal, true, true);
}
showString(tmpStr3000, &numericFont, SCREEN_WIDTH - w, Y_POSITION_OF_REGISTER_X_LINE - REGISTER_LINE_HEIGHT*(regist - REGISTER_X), vmNormal, false, true);
}
else if(temporaryInformation == TI_X_Y) {
if(regist == REGISTER_X) {
strcpy(prefix, "x" STD_SPACE_FIGURE "=");
......
......@@ -359,14 +359,15 @@ typedef int16_t calcRegister_t;
#define TI_NO_INFO 0
#define TI_RESET 1
#define TI_RADIUS_THETA 2
#define TI_X_Y 3
#define TI_RE_IM 4
#define TI_STATISTIC_SUMS 5
#define TI_ARE_YOU_SURE 6
#define TI_VERSION 7
#define TI_WHO 8
#define TI_FALSE 9
#define TI_TRUE 10
#define TI_THETA_RADIUS 3
#define TI_X_Y 4
#define TI_RE_IM 5
#define TI_STATISTIC_SUMS 6
#define TI_ARE_YOU_SURE 7
#define TI_VERSION 8
#define TI_WHO 9
#define TI_FALSE 10
#define TI_TRUE 11
// Register browser mode
#define RBR_GLOBAL 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment