help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
swift-ios-calculator
RSK World
swift-ios-calculator
Swift iOS Calculator v1.0 - AI Math Solver + 3D Graphing + Apple Watch Integration + iOS Widgets + Siri Shortcuts + Currency Converter + Scientific Calculator + Matrix Operations + Platform Integration + Modern iOS Development
swift-ios-calculator
  • Assets.xcassets
  • Base.lproj
  • swift-ios-calculator.xcodeproj
  • AIMathSolverViewController.swift26.6 KB
  • AppDelegate.swift1.7 KB
  • CalculatorHistoryViewController.swift6.5 KB
  • CalculatorLogic.swift4.4 KB
  • CalculatorSettingsViewController.swift5.6 KB
  • CalculatorTheme.swift8.3 KB
  • CalculatorUtils.swift6.9 KB
  • CalculatorViewController.swift3.4 KB
  • CalculatorWidget.swift14.3 KB
  • CalculatorWidgetInfo.plist846 B
  • ChemistryCalculatorViewController.swift26.9 KB
  • CurrencyConverterViewController.swift13.3 KB
  • CustomFormulaBuilderViewController.swift22.1 KB
  • EngineeringCalculatorViewController.swift25.7 KB
  • EquationSolverViewController.swift22.8 KB
  • FinancialCalculatorViewController.swift27.5 KB
  • GeometryCalculatorViewController.swift29.7 KB
  • Graphing3DViewController.swift20.8 KB
  • GraphingCalculatorViewController.swift14.7 KB
  • Info.plist3.2 KB
  • LICENSE1.1 KB
  • MainTabBarController.swift22.3 KB
  • MatrixCalculatorViewController.swift26.6 KB
  • PRIVACY_POLICY.md1.6 KB
  • PhysicsCalculatorService.swift8.2 KB
  • ProgrammerCalculatorViewController.swift11 KB
  • README.md8.7 KB
  • RELEASE_NOTES.md6.5 KB
  • SceneDelegate.swift2.8 KB
  • ScientificCalculatorViewController.swift6.2 KB
  • SiriShortcutsManager.swift23.5 KB
  • Swift iOS Calculator.entitlements1.1 KB
  • UnitConverterViewController.swift14 KB
  • WatchCalculatorViewController.swift15.3 KB
  • index.html47.5 KB
Swift iOS Calculator.entitlementsPhysicsCalculatorService.swift
Swift iOS Calculator.entitlements

This file cannot be displayed in the browser.

Download File
PhysicsCalculatorService.swift
Raw Download
Find: Go to:
//
//  PhysicsCalculatorService.swift
//  Swift iOS Calculator
//
//  Created by RSK World on 23/01/2026.
//  Copyright © 2026 RSK World. All rights reserved.
//
//  Developer: Molla Samser (Founder, RSK World)
//  Designer & Tester: Rima Khatun
//  Contact: info@rskworld.com, +91 93305 39277
//  Website: https://rskworld.in
//  Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147
//

import Foundation

class PhysicsCalculatorService {
    
    // MARK: - Mechanics Calculations
    func calculateKineticEnergy(mass: Double, velocity: Double) -> PhysicsCalculationResult {
        let energy = 0.5 * mass * velocity * velocity
        return .kineticEnergy(energy: energy)
    }
    
    func calculatePotentialEnergy(mass: Double, height: Double) -> PhysicsCalculationResult {
        let energy = mass * 9.81 * height
        return .potentialEnergy(energy: energy)
    }
    
    func calculateMomentum(mass: Double, velocity: Double) -> PhysicsCalculationResult {
        let momentum = mass * velocity
        return .momentum(momentum: momentum)
    }
    
    func calculateForce(mass: Double, acceleration: Double) -> PhysicsCalculationResult {
        let force = mass * acceleration
        return .force(force: force)
    }
    
    func calculateWork(force: Double, distance: Double) -> PhysicsCalculationResult {
        let work = force * distance
        return .work(work: work)
    }
    
    func calculatePower(energy: Double, time: Double) -> PhysicsCalculationResult {
        let power = energy / time
        return .power(power: power)
    }
    
    func calculateProjectile(velocity: Double, angle: Double) -> PhysicsCalculationResult {
        let angleRad = angle * Double.pi / 180
        let range = (velocity * velocity * sin(2 * angleRad)) / 9.81
        let maxHeight = (velocity * velocity * sin(angleRad) * sin(angleRad)) / (2 * 9.81)
        let timeOfFlight = (2 * velocity * sin(angleRad)) / 9.81
        return .projectile(range: range, maxHeight: maxHeight, timeOfFlight: timeOfFlight)
    }
    
    func calculateCircular(mass: Double, velocity: Double, radius: Double) -> PhysicsCalculationResult {
        let centripetalForce = mass * velocity * velocity / radius
        return .circular(centripetalForce: centripetalForce)
    }
    
    // MARK: - Thermodynamics Calculations
    func calculateIdealGas(pressure: Double, volume: Double, moles: Double, temperature: Double) -> PhysicsCalculationResult {
        return .idealGas(pressure: pressure, volume: volume, temperature: temperature)
    }
    
    func calculateHeat(mass: Double, heatCapacity: Double, temperatureChange: Double) -> PhysicsCalculationResult {
        let heat = mass * heatCapacity * temperatureChange
        return .heat(heat: heat)
    }
    
    func calculateEfficiency(outputEnergy: Double, inputEnergy: Double) -> PhysicsCalculationResult {
        let efficiency = (outputEnergy / inputEnergy) * 100
        return .efficiency(efficiency: efficiency)
    }
    
    func calculateEntropy(heat: Double, temperature: Double) -> PhysicsCalculationResult {
        let entropy = heat / temperature
        return .entropy(entropy: entropy)
    }
    
    // MARK: - Optics Calculations
    func calculateLens(focalLength: Double, objectDistance: Double) -> PhysicsCalculationResult {
        let imageDistance = 1 / (1/focalLength - 1/objectDistance)
        let magnification = -imageDistance / objectDistance
        return .lens(imageDistance: imageDistance, magnification: magnification)
    }
    
    func calculateMirror(focalLength: Double, objectDistance: Double) -> PhysicsCalculationResult {
        let imageDistance = 1 / (1/focalLength - 1/objectDistance)
        let magnification = -imageDistance / objectDistance
        return .mirror(imageDistance: imageDistance, magnification: magnification)
    }
    
    func calculateSnell(refractiveIndex: Double, angle: Double) -> PhysicsCalculationResult {
        let angleRad = angle * Double.pi / 180
        let refractedAngleRad = asin(sin(angleRad) / refractiveIndex)
        let refractedAngle = refractedAngleRad * 180 / Double.pi
        return .snell(refractedAngle: refractedAngle)
    }
    
    func calculateDiffraction(wavelength: Double, slitWidth: Double, angle: Double) -> PhysicsCalculationResult {
        let angleRad = angle * Double.pi / 180
        let order = (slitWidth * sin(angleRad)) / wavelength
        return .diffraction(order: order)
    }
    
    // MARK: - Electricity Calculations
    func calculateOhm(voltage: Double, current: Double, resistance: Double) -> PhysicsCalculationResult {
        return .ohm(voltage: voltage, current: current, resistance: resistance)
    }
    
    func calculateElectricPower(voltage: Double, current: Double) -> PhysicsCalculationResult {
        let power = voltage * current
        return .electricPower(power: power)
    }
    
    func calculateCapacitance(capacitance: Double, voltage: Double) -> PhysicsCalculationResult {
        let charge = capacitance * voltage
        return .capacitance(charge: charge)
    }
    
    func calculateInductance(inductance: Double, currentChange: Double) -> PhysicsCalculationResult {
        let voltage = inductance * currentChange
        return .inductance(voltage: voltage)
    }
    
    // MARK: - Wave Calculations
    func calculateWaveSpeed(wavelength: Double, frequency: Double) -> PhysicsCalculationResult {
        let speed = wavelength * frequency
        return .waveSpeed(speed: speed)
    }
    
    func calculateFrequency(period: Double) -> PhysicsCalculationResult {
        let frequency = 1 / period
        return .frequency(frequency: frequency)
    }
    
    func calculateDoppler(velocity: Double, frequency: Double) -> PhysicsCalculationResult {
        let speedOfSound = 343.0 // m/s
        let observedFrequency = frequency * (speedOfSound + velocity) / speedOfSound
        return .doppler(observedFrequency: observedFrequency)
    }
    
    // MARK: - Modern Physics Calculations
    func calculateRelativity(mass: Double) -> PhysicsCalculationResult {
        let speedOfLight = 299792458.0 // m/s
        let energy = mass * speedOfLight * speedOfLight
        return .relativity(energy: energy)
    }
    
    func calculateQuantum(wavelength: Double) -> PhysicsCalculationResult {
        let planckConstant = 6.62607015e-34 // J·s
        let speedOfLight = 299792458.0 // m/s
        let energy = planckConstant * speedOfLight / wavelength
        return .quantum(energy: energy)
    }
    
    func calculatePhotoelectric(wavelength: Double) -> PhysicsCalculationResult {
        let planckConstant = 6.62607015e-34 // J·s
        let speedOfLight = 299792458.0 // m/s
        let workFunction = 4.5 // eV (typical for metals)
        let photonEnergy = planckConstant * speedOfLight / wavelength
        let kineticEnergy = photonEnergy - workFunction * 1.602176634e-19
        return .photoelectric(kineticEnergy: kineticEnergy)
    }
}

enum PhysicsCalculationResult {
    case kineticEnergy(energy: Double)
    case potentialEnergy(energy: Double)
    case momentum(momentum: Double)
    case force(force: Double)
    case work(work: Double)
    case power(power: Double)
    case projectile(range: Double, maxHeight: Double, timeOfFlight: Double)
    case circular(centripetalForce: Double)
    case idealGas(pressure: Double, volume: Double, temperature: Double)
    case heat(heat: Double)
    case efficiency(efficiency: Double)
    case entropy(entropy: Double)
    case lens(imageDistance: Double, magnification: Double)
    case mirror(imageDistance: Double, magnification: Double)
    case snell(refractedAngle: Double)
    case diffraction(order: Double)
    case ohm(voltage: Double, current: Double, resistance: Double)
    case electricPower(power: Double)
    case capacitance(charge: Double)
    case inductance(voltage: Double)
    case waveSpeed(speed: Double)
    case frequency(frequency: Double)
    case doppler(observedFrequency: Double)
    case relativity(energy: Double)
    case quantum(energy: Double)
    case photoelectric(kineticEnergy: Double)
}
198 lines•8.2 KB
swift

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer