it may not deliver what you expect. For example:
if you are using NASA/JPL/Standish equations of heliocentric planetary motion, it requires:
"3. Modulus the mean anomaly (M) so that -180deg<=M<=+180deg and then obtain the eccentric anomaly, E, from the solution of Kepler's equation..."
If you attempt to use the Swift "Modulo operator, %" you'll get the Xcode directive to use truncatingRemainder instead.
Which IS better than % because of this note in "The Swift Programming Language (Swift 5.3)":
"“NOTE
The remainder operator (%) is also known as a modulo operator in other languages. However, its behavior in Swift for negative numbers means that, strictly speaking, it’s a remainder rather than a modulo operation.”
Excerpt From
The Swift Programming Language (Swift 5.3)
Apple Inc.
https://books.apple.com/us/book/the-swift-programming-language-swift-5-5/id881256329
This material may be protected by copyright.
But you should try truncatingRemainder in your playground!
Let: 0deg = 12 O'clock, 180/-180deg = 6 O'clock, -90deg = 9 O'clock and +90deg = 3 O'clock
Now run this on your playground:
let M = -181.25
var M180 = M
while M180 > 180.0 { M180 -= 360.0 }
while M180 < -180.0 { M180 += 360.0 }
print("M = \(M)\t\tM180 = \(M180)\t\tM.truncatingRemainder(dividingBy: 180.0) = \(M.truncatingRemainder(dividingBy: 180.0))\t\tM.truncatingRemainder(dividingBy: 360.0) = \(M.truncatingRemainder(dividingBy: 360.0))")
and you'll get this result:
M = -181.25
M180 = 178.75
M.truncatingRemainder(dividingBy: 180.0) = -1.25
M.truncatingRemainder(dividingBy: 360.0) = -181.25
Thus, truncatingRemainder(dividingBy: 180.0) puts your planet 180deg away from where it should be, while M180 keeps the planets moving without quantum leaps.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
MAGMA API runs on NVIDIA or AMD GPU's via CUDA.
Are there plans to code Accelerate for Metal?
Thanks
I have a small .mov I created using screenshot and I want to use it as a preview. I have managed to resize it to the required 1920x1080, added a sound track using ffmpeg (home-brew), drop it into an iMovie App preview project, share it as a file, drag that file to App Store Connect/Apps/myApp/"App previews and Screenshots" only to have it rejected for "frame rate too high", 30 fps required. There appears to be no way to specify frame rate in "Screenshot" nor iMovie during "share". Aside from using a third party app "Handbrake" to edit the file, what can be done?
Maybe more importantly, why is 30 fps required when it isn't a standard output of screenshot nor iMovie/AppPreviewProject ?
btw: iMovie/AppPreview/Help shows submittal of non-1920x1080 files to AppStoreConnect
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
Image I/O
Media Player
App Store Connect
took a bit of experimenting...
import AVKit // macOS & iOS
class ViewController_myShow: NSViewController {
@IBOutlet var myMOV: AVPlayerView!
10.
override func viewDidLoad() {
super.viewDidLoad()
let playerView = AVPlayerView()
20.
21. playerView.translatesAutoresizingMaskIntoConstraints = false
22.
23. view.addSubview(playerView)
24.
25.
26.
27. playerView.leadingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.leadingAnchor ).isActive = true
28.
29. playerView.trailingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
30.
31. playerView.topAnchor.constraint (equalTo: view.safeAreaLayoutGuide.topAnchor ).isActive = true
32.
33. playerView.bottomAnchor.constraint (equalTo: view.safeAreaLayoutGuide.bottomAnchor ).isActive = true
34.
35.
36.
37. playerView.controlsStyle = .floating
38.
39. playerView.showsFrameSteppingButtons = true
40.
41. playerView.showsFullScreenToggleButton = true
42.
43.
44.
45. guard let path = Bundle.main.url(forResource: "myMovie", withExtension: "mov") else { return }
46.
47.
48.
49. let player = AVPlayer(url: path)
50.
51. playerView.player = player
52.
53. playerView.player?.play()
54.
55. }
56.
57. }
The StoryBoard:AttributesInspector:AVPlayerView settings don't work for me... exactly. I had to set StoryBoard:AttributesInspector:AVPlayerView:ControlsStyle:none then include lines 37-41 in my code.
The default is StoryBoard:AttributesInspector:AVPlayerView:ControlsStyle:inline which appears on screen but does nothing, i.e., no control.
Line 21 is also required to be false.
The .mov file can be File:AddFilesTo 'd or copied to Assets.xcassets
see also:
Developer Forum:
"can't get extremely simple macOS video player to work..."
https://developer.apple.com/documentation/avfoundation/media_playback_and_selection/creating_a_basic_video_player_macos
			
My ContentView has an @EnvironmentObject and a few @State var's.
The State vars are for use in TextFields, one can use a Picker or manual entry, and works fine.
The other State var is to have its value set when the user hits a Button whose action executes a host of functions that changes the values of over twenty @Published vars monitored/updated by the @EnvironmentObject vis-a-vis Combine. This TexField must also be manually set/edited when desired. Within that same Button(action:{}) the next line of code attempts to set a State var to the value of the Published EnvironmentObject that had been changed by all those functions in the previous line.
The problem is: the EnvironmentObject is not updated by the time this line of code is executed. Such that the Button must be pressed twice for the result to change the TextField.
I have scoured the web and did not find, or did not understand, what is amiss.
I have successfully used .id(UUID()) on Views to ensure updates, but this issue is within a Button/action and I wouldn't know how to implement it here as TextField is a struct, and I can't implement a View.id(UUID()) inside the Button. So far as I know.
Thanks.
My iNet works fine but Numbers.app, Pages.app etc. not downloading.
My app generates many files as large as 12 GB (limited by memory) and I use Picker() to select which to reload with FileManager(). The larger files can take three minutes to load (M2 Mini Pro) and it would be nice to have progress indication like Apple's App Store downloads with the mini spinner, file size and bytes loaded.
From what I've read in "Developer Documentation", I must use a URLdelegate instance I have created, not the shared delegate, when effecting a URL download. "Downloading files in the Background" shows iOS code, not macOS, and it also uses a "shared" delegate.
A post, here, dated years ago said what I seek is not possible and I have not found recent sample code to show otherwise.
Can anyone shed light on this?
Thanks
SceneKit SCNScene MacOS 15.1 Xcode 16.0
SceneView(scene: , options:[autoenablesDefaultLighting, allowsCameraContol]
there is:
.rootNode.cameraNode
.rootNode.camera
.rootNode.nestedChildNodes each with its own animation
when the object is animated and dragged by mouse to change the view point, I can't return the view to the previous view.
I have reinstated a clone of the original cameraNode, positions of all childNodes, removed and re-activated all animations... in vain.
I have also cloned, removed and replaced .rootNode.camera, in vain.
The documentation states the camera is "attached" to an SCNNode but does not say how. I make no declaration to associate .rootNode.cameraNode to .rootNode.camera yet if either is absent there is no scene to view.
What am I missing?
Thanks
Topic:
Graphics & Games
SubTopic:
SceneKit
I accidentally added my ContentView for my project into my local Developer Documentation and I cannot get rid of it.
The Edit/delete menu item is dim when my file is selected.
Topic:
Developer Tools & Services
SubTopic:
Xcode
I have "http://localhost:8080" showing the index page I've created but php is not handled though an extension is running.
Haven't even tried mySQL yet but since there is no reference to it in https.conf the same problem will exist. Homebrew extension running also.
https.conf:
#PHP was deprecated in macOS 11 and removed from macOS 12
#LoadModule php7_module libexec/apache2/libphp7.so
There are no php.so files on my machine and again no mention of mysql
What should I enter in http.conf to activate these functionalities?
Thanks.
PS could you reference a tutorial on using Safari and Web inspector
by selecting Help under my Help menu item or cmd-h no window appears until the menu bar is touched.
myApp.swift file:
import SwiftUI
import QuickLook
@main
struct myApp: App {
@Environment(\.openWindow) var openWindow
@State var helpURL: URL? = nil
var body: some Scene {
WindowGroup {
ContentView()
}
.commandsReplaced {
CommandGroup(before: .appInfo) {
Button("Quit") {
NSApp.terminate(nil)
}.keyboardShortcut("q")
}
CommandGroup(before: .help) {
//FIXME: only shows help if the menu bar is touched again.
Button("Help") {
helpURL = Bundle.main.url(forResource: "help", withExtension: "txt")
}
.keyboardShortcut("h")
.quickLookPreview($helpURL)
}
}
}
}
How should this be coded for proper action?
Thanks
Topic:
App & System Services
SubTopic:
General
I am porting a functioning Swift App to SwiftUI with the ambitious intention of Multiple platform coding, so the project was created as such.
I've worked out every issue except as the title suggests.
My pertinent code:
import SwiftUI
import SceneKit
struct ContentView: View {
var scene : SCNScene = SCNScene = { () -> SCNScene in // DO NOT REPLACE OR MODIFY THE FIRST AND LAST LINES OF THIS VAR DECLARATION, e.g., "var scene:SCNScene{ ... }" else initScene(newScene) FAILS to create children!
let newScene = SCNScene()
initScene(newScene) // adds ChildNodes named: "precession" & "nuclearSpin"
let newCamera = SCNNode()
newCamera.position = SCNVector3(x: 0, y: 0 ,z: 40)
newCamera.name = "cameraNode"
newCamera.camera = SCNCamera()
newScene.rootNode.addChildNode(newCamera)
10. newScene.fogDensityExponent = 0.0 return newScene
}()
@EnvironmentObject var structures:Structures
@State private var Ncv = Int()
@State private var indexMomentcv = Int()
var body: some View {
ZStack{
20. SceneView(
21. scene: scene,
22. pointOfView: scene.rootNode.childNode(withName: "cameraNode", recursively: false),
23. options: [.allowsCameraControl, .autoenablesDefaultLighting, .temporalAntialiasingEnabled]
24. ).colorInvert()
25. VStack(alignment: .trailing){
26. Group{
27. HStack{
28. VStack{ // ... and so on
29.
I have verified the existence of all nodes created for the scene, i.e., the objects to be seen, using these useful functions:
func printChildNodeHierarchy(node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode ) } ) } // SUPER handy
func printChildNodeTransform(node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode.name!,"\t", anyNode.simdTransform,"\t",anyNode.scale ) } ) }
func printChildNodeAction (node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode.name!,"\t", anyNode.hasActions,"\t",anyNode.actionKeys ) } ) }
...which print in the debugging area. I have verified the materials assignments to the elements of those nodes. So, everything is in place as in the functioning Swift/macOS App but I just don't see the objects.
What I've tried:
Since I run in DarkMode theme I have cycled through the combinations of Dark/Light and with/without line 24's .colorInvert() and swapping ZStack with HStack.
Some combo's do wash-out, but still no objects.
I zero'd out the fog thinking it might be too foggy. Not.
I've created a scene.scn file as a resource, applied the above attributes to it, reference it with scene = SCNScene(named: scene.scn"), but get the same non-result.
Idk if some checkbox is errant in the build/target etc. area. Wouldn't know if it was. I'm not a professional programmer.
Any thoughts are appreciated. I've been stuck for days.
oh yeah: as of this posting I am up to date on all Apple software, running 2018 MacMini/Intel/SSD
As stated in the title, I want to hide or show a StackView when a menu item is selected, which in turn changes a global variable.
How do I access the identity or handle of the StackView?
My SceneView hides part of my NSStackView's TextFields. I don't see anything in the inspector for the z dimension. How can I ensure the StackView is on top, i.e., wholly visible?
I don't want to shove views around to "fit them in". They must overlap.
Indeed, I may wish to have all TextFields, etc. overlay the SceneView in the future, but that's a different subject.
I know this would be easy in SwiftUI, but...
Developing a program that needs maximum cores. My previous Intel Mac mini used all 6 cores, according to Activity Monitor. It showed 600% cpu usage. I assumed the M2 would use twelve, but only shows 400% cpu usage in Activity Monitor, ergo, two less!
I don't recall setting a core usage parameter in Xcode.
Any ideas?
Ventura 13.3 and Xcode 14.3 up to date as of this post.