1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
//! Algebraic product traits for Geometric Algebra.
//!
//! This module defines traits for the various products in Geometric Algebra.
//! These traits enable method-based APIs for products, improving discoverability
//! through IDE autocomplete.
//!
//! # Products Overview
//!
//! | Trait | Symbol | Description |
//! |-------|--------|-------------|
//! | [`Wedge`] | `∧` | Exterior/wedge product (grade-raising) |
//! | [`Antiwedge`] | `∨` | Regressive product (antigrade-raising) |
//! | [`Join`] | `∨` | Alias for Wedge (PGA terminology) |
//! | [`Meet`] | `∧` | Alias for Antiwedge (PGA terminology) |
//! | [`Dot`] | `•` | Metric dot product (same-grade only) |
//! | [`Antidot`] | `⊚` | Metric antidot product |
//! | [`LeftContract`] | `⌋` | Left contraction |
//! | [`RightContract`] | `⌊` | Right contraction |
//! | [`BulkContract`] | `a ∨ b★` | Bulk contraction |
//! | [`WeightContract`] | `a ∨ b☆` | Weight contraction |
//! | [`Project`] | `b ∨ (a ∧ b☆)` | Projection onto geometry |
//! | [`Antiproject`] | `b ∧ (a ∨ b☆)` | Antiprojection onto geometry |
//! | [`Sandwich`] | `v × x × ṽ` | Sandwich product |
//! | [`Versor`] | `a ⟇ b` | Versor composition |
//!
//! # Type Safety
//!
//! All product traits in this module are **type-safe**: the output type is
//! determined by the input types and the product kind. This is achieved by:
//!
//! - **Grade-preserving products** (Sandwich, Antisandwich) return the same type
//! - **Grade-changing products** (Wedge, Antiwedge) have deterministic output grades
//! - **Scalar products** (Dot, Antidot) always return the scalar type
//!
//! The geometric product is **not** provided as a trait because it produces
//! mixed-grade outputs that cannot be represented by a single specialized type.
//! Use the grade-specific products instead.
//!
//! # Example
//!
//! ```ignore
//! use clifford::ops::{Wedge, Sandwich, Dot};
//! use clifford::specialized::projective::dim3::{Point, Motor};
//!
//! // Create a line through two points using wedge product
//! let line = p1.wedge(&p2);
//!
//! // Transform a point using sandwich product
//! let transformed = motor.sandwich(&point);
//!
//! // Compute dot product for angles/magnitudes
//! let cos_angle = v1.dot(&v2);
//! ```
//!
//! # Implementation
//!
//! These traits are implemented by the code generator for specialized types.
//! The implementations delegate to optimized free functions.
/// Wedge (exterior) product.
///
/// The wedge product `a ∧ b` is grade-raising: `grade(a ∧ b) = grade(a) + grade(b)`.
/// It represents the "span" of two elements - two vectors wedged give the plane they span.
///
/// # Properties
///
/// - Antisymmetric: `a ∧ b = -(b ∧ a)`
/// - Associative: `(a ∧ b) ∧ c = a ∧ (b ∧ c)`
/// - `a ∧ a = 0` for vectors
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Wedge;
///
/// // Line through two points
/// let line = p1.wedge(&p2);
///
/// // Plane through point and line
/// let plane = point.wedge(&line);
/// ```
/// Antiwedge (regressive) product.
///
/// The antiwedge product `a ∨ b` is antigrade-raising. It's the dual of the wedge product
/// and computes the "meet" of geometric elements.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Antiwedge;
///
/// // Point where two lines meet
/// let point = line1.antiwedge(&line2);
///
/// // Line where two planes meet
/// let line = plane1.antiwedge(&plane2);
/// ```
/// Left contraction.
///
/// The left contraction `a ⌋ b` projects `b` onto elements orthogonal to `a`.
/// Result is grade `grade(b) - grade(a)` when `grade(a) ≤ grade(b)`, else zero.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::LeftContract;
///
/// // Contract a vector with a bivector
/// let result = vector.left_contract(&bivector);
/// ```
/// Right contraction.
///
/// The right contraction `a ⌊ b` is the dual of left contraction.
/// Result is grade `grade(a) - grade(b)` when `grade(b) ≤ grade(a)`, else zero.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::RightContract;
///
/// let result = bivector.right_contract(&vector);
/// ```
/// Bulk contraction (`a ∨ b★`).
///
/// The bulk contraction is the antiwedge of `a` with the bulk dual of `b`.
/// Used for projections in PGA.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::BulkContract;
///
/// let projected = element.bulk_contract(&other);
/// ```
/// Weight contraction (`a ∨ b☆`).
///
/// The weight contraction is the antiwedge of `a` with the weight dual of `b`.
/// Used for projections in PGA.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::WeightContract;
///
/// let projected = element.weight_contract(&other);
/// ```
/// Bulk expansion (`a ∧ b★`).
///
/// The bulk expansion is the wedge of `a` with the bulk dual of `b`.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::BulkExpand;
///
/// let result = element.bulk_expand(&other);
/// ```
/// Weight expansion (`a ∧ b☆`).
///
/// The weight expansion is the wedge of `a` with the weight dual of `b`.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::WeightExpand;
///
/// let result = element.weight_expand(&other);
/// ```
/// Scalar product.
///
/// The scalar product extracts only the grade-0 (scalar) part of the geometric product.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::ScalarProduct;
///
/// let s: f64 = a.scalar_product(&b);
/// ```
/// Sandwich product (`v × x × ṽ`).
///
/// The sandwich product transforms `x` by the versor `v`. This is the fundamental
/// transformation operation in GA - rotors, motors, and flectors all transform
/// elements via sandwich products.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Sandwich;
///
/// // Transform a point by a motor
/// let transformed_point = motor.sandwich(&point);
///
/// // Rotate a vector by a rotor
/// let rotated = rotor.sandwich(&vector);
/// ```
/// Antisandwich product (`v ⟇ x ⟇ ṽ`).
///
/// The antisandwich product is the complement of the sandwich product,
/// used for transforming elements via the geometric antiproduct.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Antisandwich;
///
/// let transformed = flector.antisandwich(&element);
/// ```
/// Inverse sandwich product (`v × x × v⁻¹`).
///
/// The inverse sandwich uses the multiplicative inverse instead of the reverse.
/// This correctly handles **non-unit versors** where `rev(v) ≠ v⁻¹`.
///
/// # Comparison with Sandwich
///
/// | Product | Formula | When to use |
/// |---------|---------|-------------|
/// | Sandwich | `v × x × rev(v)` | Unit versors only (`\|v\| = 1`) |
/// | InverseSandwich | `v × x × v⁻¹` | Any versor (unit or non-unit) |
///
/// For **unit versors** (where `|v| = 1`), both products are equivalent since
/// `rev(v) = v⁻¹`. For **non-unit versors**, Sandwich scales the result by
/// `|v|²` while InverseSandwich gives the correct transformation.
///
/// # When to Use
///
/// - Use `Sandwich` for performance when working with normalized versors
/// - Use `InverseSandwich` when versors may not be normalized, or when
/// you need mathematically correct results regardless of scaling
///
/// # Example
///
/// ```ignore
/// use clifford::ops::InverseSandwich;
///
/// // Works correctly even if motor is not normalized
/// let unnormalized_motor = Motor::from_translation(10.0, 20.0, 30.0);
/// let transformed = unnormalized_motor.try_inverse_sandwich(&point);
/// ```
/// Inverse antisandwich product (`v ⊛ x ⊛ v⁻¹`).
///
/// The inverse antisandwich uses the multiplicative inverse with the antiproduct.
/// This correctly handles **non-unit versors** in degenerate algebras (PGA).
///
/// # Comparison with Antisandwich
///
/// | Product | Formula | When to use |
/// |---------|---------|-------------|
/// | Antisandwich | `v ⊛ x ⊛ antirev(v)` | Unit versors only |
/// | InverseAntisandwich | `v ⊛ x ⊛ v⁻¹` | Any versor (unit or non-unit) |
///
/// # Example
///
/// ```ignore
/// use clifford::ops::InverseAntisandwich;
///
/// let result = motor.try_inverse_antisandwich(&point);
/// ```
/// Dot product (metric inner product).
///
/// The dot product `a • b` is non-zero only when `grade(a) = grade(b)`.
/// It measures the "alignment" between same-grade elements using the metric.
///
/// Defined as: `a • b = aᵀ G b` where G is the metric exomorphism matrix.
///
/// # Properties
///
/// - Only same-grade elements produce non-zero results
/// - Symmetric: `a • b = b • a`
/// - Returns a scalar
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Dot;
///
/// let cos_angle: f64 = vector1.dot(&vector2);
/// let bivector_magnitude_sq: f64 = bivector.dot(&bivector);
/// ```
///
/// # Reference
///
/// [RGA Dot Products](https://rigidgeometricalgebra.org/wiki/index.php?title=Dot_products)
/// Antidot product (metric antiproduct inner product).
///
/// The antidot product `a ⊚ b` is the De Morgan dual of the dot product:
/// `a ⊚ b = ā • b̄` (complement dot complement).
///
/// Defined as: `a ⊚ b = aᵀ 𝔾 b` where 𝔾 is the metric antiexomorphism matrix.
///
/// # Properties
///
/// - Only same-antigrade elements produce non-zero results
/// - Symmetric
/// - Returns a scalar
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Antidot;
///
/// let result: f64 = plane1.antidot(&plane2);
/// ```
///
/// # Reference
///
/// [RGA Dot Products](https://rigidgeometricalgebra.org/wiki/index.php?title=Dot_products)
// ============================================================================
// Unary Operations
// ============================================================================
/// Reverse operation.
///
/// The reverse `ã` reverses the order of basis vectors in each blade.
/// For a blade of grade k: `rev(e₁e₂...eₖ) = eₖ...e₂e₁ = (-1)^(k(k-1)/2) * blade`.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Reverse;
///
/// let reversed = bivector.reverse();
/// ```
/// Antireverse operation.
///
/// The antireverse `a̲` (tilde below) is the antiproduct complement of reverse.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Antireverse;
///
/// let antireversed = element.antireverse();
/// ```
/// Involute (algebra-specific norm involution).
///
/// The involute operation is used for computing norms in the algebra.
/// Different algebras use different involutions for their canonical norm:
///
/// | Algebra | Involution | Sign for grade k |
/// |---------|------------|------------------|
/// | Euclidean | Reverse | `(-1)^(k(k-1)/2)` |
/// | PGA | Reverse | `(-1)^(k(k-1)/2)` |
/// | Hyperbolic | Grade involution | `(-1)^k` |
///
/// The norm squared is computed as `x * involute(x)`.
///
/// # Note
///
/// This is separate from [`Reverse`] because versors always use the reverse
/// for transformation (since `reverse(AB) = reverse(B) × reverse(A)`), but
/// the norm uses the algebra's canonical involution.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Involute;
///
/// let z = Hyperbolic::new(3.0, 4.0);
/// let inv = z.involute();
/// let norm_sq = z * inv; // norm_squared for hyperbolic numbers
/// ```
/// Right complement operation.
///
/// The right complement `ā` (bar above) satisfies: `a ∧ ā = 𝟙` (pseudoscalar).
///
/// # Example
///
/// ```ignore
/// use clifford::ops::RightComplement;
///
/// let complement = vector.right_complement();
/// ```
/// Left complement operation.
///
/// The left complement `a̱` (bar below) satisfies: `a̱ ∧ a = 𝟙` (pseudoscalar).
///
/// # Example
///
/// ```ignore
/// use clifford::ops::LeftComplement;
///
/// let complement = vector.left_complement();
/// ```
/// Bulk dual operation.
///
/// The bulk dual `u★` is defined as: `u★ = ũ ⋙ 1` (geometric product with
/// pseudoscalar on right). For non-degenerate metrics, this equals the Hodge dual.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::BulkDual;
///
/// let dual = vector.bulk_dual();
/// ```
/// Weight dual (antidual) operation.
///
/// The weight dual `u☆` is defined as: `u☆ = ũ ⋗ 1` (antigeometric product
/// with antiscalar on right). For degenerate metrics (PGA), this differs from bulk dual.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::WeightDual;
///
/// let antidual = vector.weight_dual();
/// ```
// ============================================================================
// Versor Operations
// ============================================================================
/// Versor composition.
///
/// Versors are elements that represent transformations. This trait enables
/// composing versors where the result type may differ from the input types.
///
/// In Geometric Algebra, versors include:
///
/// - **Rotors**: Represent rotations (Euclidean and PGA)
/// - **Motors**: Represent rigid motions (rotation + translation) in PGA
/// - **Flectors**: Represent reflections and glide reflections in PGA
///
/// The `compose` method combines two versors into a single versor representing
/// the sequential application of both transformations: `(a.compose(b)).sandwich(x)`
/// is equivalent to `a.sandwich(b.sandwich(x))`.
///
/// # Mathematical Definition
///
/// For PGA versors, composition is the geometric product (which uses the
/// antigeometric structure internally). The output type depends on the inputs:
///
/// - Motor × Motor → Motor (even × even = even)
/// - Flector × Flector → Motor (odd × odd = even)
/// - Motor × Flector → Flector (even × odd = odd)
/// - Flector × Motor → Flector (odd × even = odd)
///
/// # Properties
///
/// - Associative: `a.compose(b).compose(c) = a.compose(b.compose(c))`
/// - Identity: The scalar `1` acts as identity
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Versor;
///
/// // Compose two motors (returns Motor)
/// let combined_motion: Motor<f64> = motor1.compose(&motor2);
///
/// // Compose two flectors (returns Motor)
/// let motor: Motor<f64> = flector1.compose(&flector2);
///
/// // Compose motor with flector (returns Flector)
/// let flector: Flector<f64> = motor.compose(&flector);
/// ```
///
/// # Reference
///
/// [RGA Motors](https://rigidgeometricalgebra.org/wiki/index.php?title=Motor)
/// Versor inverse.
///
/// The inverse of a versor `V` satisfies `V × V⁻¹ = 1` (scalar identity).
/// For versors, the inverse is computed as:
///
/// ```text
/// V⁻¹ = rev(V) / (V · rev(V)) = rev(V) / |V|²
/// ```
///
/// Where `rev(V)` is the reverse and `|V|²` is the norm squared.
///
/// # Unit Versors
///
/// For unit versors (where `|V|² = 1`), the inverse simplifies to just the reverse:
/// `V⁻¹ = rev(V)`. This is why unit rotors and normalized motors are preferred
/// for transformations - their inverses are trivial to compute.
///
/// # Non-invertible Case
///
/// Versors with zero norm are not invertible. The `try_inverse()` method
/// returns `None` for such cases. This can occur with:
/// - Zero versors (all components zero)
/// - Null versors in degenerate algebras
///
/// # Properties
///
/// - `V × V⁻¹ = 1` (right inverse)
/// - `V⁻¹ × V = 1` (left inverse)
/// - `(A × B)⁻¹ = B⁻¹ × A⁻¹` (reversal of composition order)
/// - For unit versors: `V⁻¹ = rev(V)`
///
/// # Example
///
/// ```ignore
/// use clifford::ops::VersorInverse;
///
/// // Get the inverse of a motor
/// let motor_inv = motor.try_inverse().expect("non-zero motor");
///
/// // Verify: motor × motor_inv ≈ identity
/// let identity = motor.compose(&motor_inv);
///
/// // For unit versors, inverse equals reverse
/// let unit_rotor = rotor.try_normalize().unwrap();
/// assert_eq!(unit_rotor.try_inverse(), Some(unit_rotor.reverse()));
/// ```
///
/// # Reference
///
/// [RGA Motors](https://rigidgeometricalgebra.org/wiki/index.php?title=Motor)
// ============================================================================
// Join and Meet (aliases for Wedge and Antiwedge)
// ============================================================================
/// Join product (alias for wedge/exterior product).
///
/// The join `a ∨ b` is the wedge product `a ∧ b`. It "joins" two geometric
/// elements to create a higher-dimensional element spanning both.
///
/// In PGA terminology:
/// - Two points joined give the line through them
/// - A point and line joined give the plane containing both
/// - A point, line, and plane joined give the volume
///
/// # Relationship to Wedge
///
/// This trait is automatically implemented for any type implementing [`Wedge`].
/// It provides a more intuitive name for PGA operations.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Join;
///
/// // Line through two points
/// let line = p1.join(&p2);
///
/// // Plane through point and line
/// let plane = point.join(&line);
/// ```
///
/// # Reference
///
/// [RGA Wedge Product](https://rigidgeometricalgebra.org/wiki/index.php?title=Wedge_product)
/// Blanket implementation of Join for any type implementing Wedge.
/// Meet product (alias for antiwedge/regressive product).
///
/// The meet `a ∧ b` is the antiwedge product `a ∨ b`. It finds the
/// "intersection" of two geometric elements.
///
/// In PGA terminology:
/// - Two planes meet at a line
/// - A plane and line meet at a point
/// - Two lines meet at a point (if they intersect)
///
/// # Relationship to Antiwedge
///
/// This trait is automatically implemented for any type implementing [`Antiwedge`].
/// It provides a more intuitive name for PGA operations.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Meet;
///
/// // Line where two planes intersect
/// let line = plane1.meet(&plane2);
///
/// // Point where plane and line intersect
/// let point = plane.meet(&line);
/// ```
///
/// # Reference
///
/// [RGA Antiwedge Product](https://rigidgeometricalgebra.org/wiki/index.php?title=Antiwedge_product)
/// Blanket implementation of Meet for any type implementing Antiwedge.
/// Transform operation (alias for antisandwich product).
///
/// The transform `versor.transform(element)` is the antisandwich product
/// `versor ⊛ element ⊛ rev(versor)` where ⊛ is the geometric antiproduct.
///
/// In PGA, transformations (rotations, translations, reflections) are applied
/// via the antisandwich product. This trait provides a more intuitive name
/// for this operation.
///
/// # Implementation
///
/// Transform implementations are generated by codegen based on the algebra's signature:
/// - **Degenerate** (has zero elements like e0² = 0): delegates to [`Antisandwich`]
/// - **Non-degenerate** (no zero elements): delegates to [`Sandwich`]
///
/// This distinction exists because degenerate metrics cause sandwich terms to vanish,
/// requiring the antisandwich (which uses complements) to preserve information.
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Transform;
///
/// // Apply motor (rotation + translation) to a point
/// let transformed_point = motor.transform(&point);
///
/// // Apply motor to a line
/// let transformed_line = motor.transform(&line);
///
/// // Apply motor to a plane
/// let transformed_plane = motor.transform(&plane);
/// ```
///
/// # Reference
///
/// [RGA Transformations](https://rigidgeometricalgebra.org/wiki/index.php?title=Transformations)
// Transform implementations are generated by codegen based on signature:
// - Degenerate signature (has zero elements like e0² = 0): uses antisandwich
// - Non-degenerate signature (no zero elements): uses sandwich
// ============================================================================
// Projections
// ============================================================================
/// Projection of self onto target geometry.
///
/// The projection `proj_b(a)` finds the part of `a` that lies on `b`.
/// For a point projected onto a line or plane, this gives the closest
/// point on that geometry.
///
/// # Formula
///
/// `proj_b(a) = b ∨ (a ∧ b☆)`
///
/// Where:
/// - `∨` is the antiwedge (regressive) product
/// - `∧` is the wedge (exterior) product
/// - `b☆` is the weight dual of `b`
///
/// # Geometric Interpretation
///
/// | Self | Target | Result | Meaning |
/// |------|--------|--------|---------|
/// | Point | Line | Point | Closest point on line |
/// | Point | Plane | Point | Closest point on plane |
/// | Line | Plane | Line | Line's projection onto plane |
///
/// # Properties
///
/// - **Idempotent**: projecting onto the same geometry twice gives the same result
/// - **Orthogonality**: the difference between an object and its projection is
/// orthogonal to the target
/// - **Grade preservation**: projection of a point onto a line/plane yields a point
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Project;
/// use clifford::specialized::projective::dim3::{Point, Line};
///
/// let point = Point::from_cartesian(1.0, 2.0, 3.0);
/// let line = Line::x_axis();
/// let closest = point.project(&line); // Closest point on x-axis
/// ```
///
/// # Reference
///
/// [RGA Projections](https://rigidgeometricalgebra.org/wiki/index.php?title=Projections)
/// Antiprojection of self onto target geometry.
///
/// The antiprojection `antiproj_b(a)` finds the geometry through `a` that is
/// perpendicular to `b`. It is the dual operation to projection.
///
/// # Formula
///
/// `antiproj_b(a) = b ∧ (a ∨ b☆)`
///
/// Where:
/// - `∧` is the wedge (exterior) product
/// - `∨` is the antiwedge (regressive) product
/// - `b☆` is the weight dual of `b`
///
/// # Geometric Interpretation
///
/// | Self | Target | Result | Meaning |
/// |------|--------|--------|---------|
/// | Point | Line | Plane | Plane through point containing line |
/// | Point | Plane | Line | Line through point perpendicular to plane |
/// | Line | Point | Plane | Plane containing line and point |
///
/// # Example
///
/// ```ignore
/// use clifford::ops::Antiproject;
/// use clifford::specialized::projective::dim3::{Point, Plane};
///
/// let point = Point::from_cartesian(1.0, 2.0, 3.0);
/// let plane = Plane::xy();
/// let perp_line = point.antiproject(&plane); // Line through point, perpendicular to xy
/// ```
///
/// # Reference
///
/// [RGA Projections](https://rigidgeometricalgebra.org/wiki/index.php?title=Projections)
// ============================================================================
// Note: Project and Antiproject implementations are code-generated
// for specialized single-grade types to ensure only geometrically
// meaningful operations are allowed. See generated/traits.rs files.