- [email protected] (Put repository address and email on whiteboard) Making geometry is what floats my boat… There are times when expensive CAD software is not the right tool: stiffened panel and gear. Please ask questions as they occur to you.
grabbing your iPad and spending five minutes. Single path, - no cutouts, yet. Talk about 3D printed letter G, and making offsets. Might also give it thickness for display.
screen, and Pencil input. Repository is an accumulation of code written for various geometry projects. Useful for ad hoc geometry in an AR app. SolidWorks is one CAD system that has a tool to import sketches. A couple of tools that I have run across are worth sharing.
unsophisticated version. /// Adds to array 'pool'. /// - Parameters: /// - freshCurve: A newly drawn curve func add(freshCurve: PenCurve) -> Void { Lines with three slashes immediately prior to declarations using some key words Jazzy generates HTML that you can post with your repository. (Go to browsing the documentation)
5 /// The possible return value var tighter: ClosedRange<Double> /// Parameter step let parStep = (span.upperBound - span.lowerBound) / Double(chunks) Individual Parameters for Quick Help If you add a description, it shows up. Is it worth your time to add these? If come back to look at code I wrote nine months ago, I’m happy for this. What do you think is necessary for the people who will see your code?
length /// - Returns: A simple flag /// - SeeAlso: isOpposite() /// - See: 'testIsScaled' under Vector3DTests Other Keywords Warning, links, images, copyright, and note. Some keywords are bolded in XCode 9.3. I don’t know the significance of that. I do not know which ones, if any, that Jazzy ignores.
Documentation will be generated only for public functions and attributes • Perhaps not ideal for your own use. • Future use in an automated scan Claim that it uses some portion of the compiler to understand the source code. A little extra time while coding avoids maintaining a separate document. Audience willingness and ability to read code? Future you? I am trying to cultivate the habit of writing structured comments as I write code.
results. Percentage for the project is shown at the top. Don’t get hung up on meeting some coverage number. ViewController will never be 100% Might tell you if one class is ready for prime time. Tests are like the merge lanes on city streets.
Switch case that hasn’t been proven will stand out. Does anyone know what the stripes indicate? This doesn’t mean that there are 62 XCTAsserts being used.
• Useful for regression testing when requirements change. For an open source project, do the tests provide the equivalent of guard rails? “The software is never finished and requirements tend to change.” For an open source project, you might need to help a wide spectrum of people.
for all classes. • There is a difference between thorough testing and complete testing. • Tests are important should I want to re-host this work to another language. • Tests are a useful check if I rework the code to speed it up. I’m willing to invest time in writing tests because I consider them assets for the lifetime of the code. I feel comfortable about the upcoming transition to Swift 5 this fall. If you have exercised each and every line, does that mean that you have covered all of the possible cases? Most of my routines pass tests in the XY plane. Should I have tests in skewed planes? This tool can help you reach your testing goal.
to break down the problem. More of an object-oriented than functional programming approach. Speak up if you see something that is going to kick my butt later.
to be extended? • Decisions about member or static functions. How many of them will be used? • Where do you put complicated functions e.g. line / line intersection? • Testing will influence how you break down your problem. Jazzy documentation doesn’t categorize member or static.
four others Point I’ve spent time pondering whether functions should belong to the instance, or the class. Compiler’s help to write routines that are thread safe. Triangle counts for the gear and stiffened panel. Automated Reference Counting helps, but you’re still on a machine with limited memory.
general framework for a curve. Not limited to 2D. public protocol PenCurve { /// The enum that hints at the meaning of the curve var usage: PenTypes { get set } /// Not used yet var parameterRange: ClosedRange<Double> { get set } /// Supply the point on the curve for the input parameter value func pointAt(t: Double) throws -> Point3D /// Retrieve the starting end func getOneEnd() -> Point3D /// Retrieve the finishing end func getOtherEnd() -> Point3D Finite curves that I want to draw and assemble into a silhouette. Not shown in this code fragment is a ‘draw’ method. (An illustration to serve as a reminder of the goal would be good.)
Ellipse Plane In the spirit of strong typing, I didn’t treat Point and Vector the same. Transform is a 4x4, not a 3x3. Transform needed to scale then display in XY. Would want to have a quadratic to go to and from SVG’s. Show construction of the fillet as rationale for Line.
a flag when it becomes closed. • Will force a consistent order when closed. Closest equivalent to UIBezierPath. Is a Class that might be extended. Use two volunteers to draw shape, then examine order used? Individual segments of a Loop will be drawn in random order, and in random directions.
enum PenTypes { case raw case construction case interior case ideal case guide case ordinary } This gets stored in one of the member attributes for PenCurve protocol. Whatever categories you need for the current project. Choices for foamboard app might be: edge, score, bevel, and A-fold.
desired pen characteristics: // Choose the appropriate pen switch wire.usage { case .raw: context.setStrokeColor(blue) context.setLineWidth(standard) context.setLineDash(phase: 0, lengths: []); case .construction: context.setStrokeColor(black) context.setLineWidth(thin) context.setLineDash(phase: 0, lengths: [CGFloat(10), CGFloat(8)]); Custom code for each application This ‘switch’ statement immediately precedes the polymorphic ‘draw’ method call. The goal is to separate out the presentation properties, and have a capable and reusable plotting scheme. Decisions about the palette are made at compile time.
Result of a stroke will be an array of points, recorded every 1/30 th of a second. Perhaps more rapidly on last year’s iPads. Our brains can differentiate those readily. Writing code to do it isn’t as easy. How do you turn that data into information? (This really should be a live demonstration)
select a curve? • Drag a box that will contain it • Short stroke across the curve • Scribble across the curve to delete it? Some of the interesting UI questions Recall that you don’t have any indication when the tip is hovering near a point.
and V coordinates Curve tools are the stepping stone to working with surfaces such as the stiffened panel Curves are also a function of U and V. Whole bunch more iterative work. That will be hard to get correct and fast. Reference a surface repository.
16 matrix. Offset curve requires a 4x4, which SIMD library can handle. C function package is callable from Swift, though that isn’t in the repository. “import Accelerate” (Add chart with code sample?) Have not tried large matrices.
functions • Plenty of ‘map’, ‘filter’, and ’reduce’, but no named closures. • (1…10).reverse() for a decrementing loop index Best example of using features of the language. Draw curve and line to show intersection process using tuples and ClosedRange. Default parameters Any discussion of access control?
letters. • SVG output is the advancement beyond screen scraping. • Output to JavaScript if running server-side Swift. • How do I tackle ‘Undo’ management? Future Commits (Come up with a beam section view to show dimensions?) Online converters available for SVG to .dwg. Where is a definition of .dwg format?
coincident class CoincidentPointsError: ErrorType { var ptA: Point3D var description: String { return "Coincident points were specified - no bueno! " + String(ptA) } init(dupePt: Point3D) { self.ptA = dupePt } } An example of how I choose to use ErrorType ErrorType has a blank protocol at the moment Description could be used on the console, on a logger, or in an alert Chose a class in case I want make a subtype