You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use xPositionDelta and yPositionDelta variables as well as a little bit of algebra for checking if the source (moveable) tangram lies within the x-axis delta or y-axis delta of the target (outline) tangram.
Before:
//Check if x coordinate is in the tolerance rangeif(this.myTanPosition.x *10<(xInTan*10+3)&&this.myTanPosition.x *10>(xInTan*10-3)){//Check if y coordinate is in the tolerance rangeif(this.myTanPosition.y *10<(yInTan*10+3)&&this.myTanPosition.y *10>(yInTan*10-3)){
Update:
privatefloatxPositionDelta=3.0f;privatefloatyPositionDelta=3.0f;//Check if x coordinate is in the tolerance rangeif(Mathf.Abs(this.myTanPosition.x *10-xInTan*10)<xPositionDelta){//Check if y coordinate is in the tolerance rangeif(Mathf.Abs(this.myTanPosition.y *10-yInTan*10)<yPositionDelta){
Math:
s = this.myTanPosition.x // source x
d = xInTan // destination x
= 10s > (10d - 3) && 10s < (10d + 3)
// rearrange 10s to be in the middle of an inequality
= 10d - 3 < 10s < 10d + 3
// subtract -10d from all expressions
= -3 < 10s - 10d < 3
// use absolute
= |10s - 10d| < 3
= |x| < 2
= -2 < x < 2
Also, why do you multiply by 10?
The text was updated successfully, but these errors were encountered:
Use
xPositionDelta
andyPositionDelta
variables as well as a little bit of algebra for checking if the source (moveable) tangram lies within the x-axis delta or y-axis delta of the target (outline) tangram.Before:
Update:
Math:
Also, why do you multiply by 10?
The text was updated successfully, but these errors were encountered: