/// <summary> /// it checks if x value is 0 in each point. /// </summary> /// <returns><c>true</c> sun is aligned <c>false</c> otherwise.</returns> /// <param name="processType">if calculation includes the sun or not.</param> private bool pointValidation(Enumerators.ProcessType processType) { double denominatorSegmentTwo = betasoide.GalaxyPosition.X - ferengi.GalaxyPosition.X; if (denominatorSegmentTwo.Equals(0.0)) { if (ferengi.GalaxyPosition.X.Equals(0.0)) { if (Enumerators.ProcessType.IncludeOrigin == processType) { return(true); } } } return(false); }
private bool MathLineFunction(Enumerators.ProcessType processType) { //calculates the slope with coordinates of two planets. //this time vulcano, betasoide //line function => y = m.x + b double denominator = (vulcano.GalaxyPosition.X - betasoide.GalaxyPosition.X); if (denominator.Equals(0.0)) { return(pointValidation(processType)); } //Slope double m = Math.Round((vulcano.GalaxyPosition.Y - betasoide.GalaxyPosition.Y) / denominator, 2); //choosing a planet calculate the b point. double b = Math.Round(vulcano.GalaxyPosition.Y - (m * vulcano.GalaxyPosition.X), 2); //check if ferengi is aligned. double yResult = Math.Round(ferengi.GalaxyPosition.Y, 2); double functionResult = Math.Round((m * ferengi.GalaxyPosition.X) + b); double difference = Math.Round(Math.Abs(yResult * ERROR_DECIMAL)); //check if sun is aligned if (Math.Abs(yResult - functionResult) <= difference) { double differenceB = Math.Abs(b * ERROR_DECIMAL); if (Math.Abs(0.0 - b) <= differenceB) { if (processType == Enumerators.ProcessType.IncludeOrigin) { return(true); } } else { if (processType == Enumerators.ProcessType.ExcludeOrigin) { return(true); } } } return(false); }