1use crate::action::Action;
15use crate::freeform::{isect_with, GridSag, ZernSag};
16use crate::grin::GrinKind;
17use crate::math::*;
18use crate::surface::{SurfType, Surface};
19
20#[derive(Debug, Clone, Copy, PartialEq)]
22pub struct Base<'a> {
23 pub c: f64,
24 pub k: f64,
25 pub a: &'a [f64],
27}
28
29impl Base<'_> {
30 pub fn has_terms(&self) -> bool {
32 self.a.iter().any(|&v| v != 0.0)
33 }
34}
35
36#[derive(Debug, Clone, Copy, PartialEq)]
39pub struct Irregular {
40 pub c: f64,
41 pub k: f64,
42 pub decenter: [f64; 2],
44 pub tilt: [f64; 2],
46 pub zs: f64,
47 pub za: f64,
48 pub zc: f64,
49 pub angle: f64,
51 pub radius: f64,
53}
54
55#[derive(Debug, Clone, Copy, PartialEq)]
57pub enum Shape<'a> {
58 Plane,
60 Conic {
62 c: f64,
63 k: f64,
64 },
65 EvenAsphere(Base<'a>),
67 OddAsphere {
69 c: f64,
70 k: f64,
71 b: &'a [f64],
72 },
73 Toroid {
76 c: f64,
77 k: f64,
78 a: &'a [f64],
79 cx: f64,
80 },
81 Zernike {
83 base: Base<'a>,
84 terms: Option<&'a ZernSag>,
85 },
86 GridSag {
88 base: Base<'a>,
89 terms: Option<&'a ZernSag>,
90 grid: Option<&'a GridSag>,
91 },
92 Tilted {
95 tan: [f64; 2],
96 c: f64,
97 k: f64,
98 },
99 ConicTilted {
101 c: f64,
102 k: f64,
103 tan: [f64; 2],
104 },
105 Cylinder(Base<'a>),
107 Irregular(Irregular),
108 User {
110 c: f64,
111 k: f64,
112 shape: &'a crate::usershape::UserShape,
113 h: f64,
115 },
116}
117
118impl Surface {
119 pub fn shape(&self) -> Shape<'_> {
121 let (c, k) = (self.c, self.k);
122 let base = Base {
123 c,
124 k,
125 a: self.asph(),
126 };
127 let p = |i: usize| self.asph().get(i).copied().unwrap_or(0.0);
128 match self.typ() {
129 SurfType::Standard | SurfType::Gradium => Shape::Conic { c, k },
130 SurfType::EvenAsph | SurfType::Binary2 => Shape::EvenAsphere(base),
131 SurfType::Toroidal => Shape::Toroid {
132 c,
133 k,
134 a: self.asph(),
135 cx: self.cx(),
136 },
137 SurfType::ZernikeStd | SurfType::ZernikeFringe => Shape::Zernike {
138 base,
139 terms: self.zern(),
140 },
141 SurfType::GridSag => Shape::GridSag {
142 base,
143 terms: self.zern(),
144 grid: self.grid(),
145 },
146 SurfType::OddAsph => Shape::OddAsphere {
147 c,
148 k,
149 b: self.asph(),
150 },
151 SurfType::TiltSurf => Shape::Tilted {
152 tan: [p(0), p(1)],
153 c,
154 k,
155 },
156 SurfType::Gradient9 => Shape::ConicTilted {
157 c,
158 k,
159 tan: match self.grin().map(|g| &g.kind) {
160 Some(GrinKind::Grad9 { tan, .. }) => *tan,
161 _ => [0.0; 2],
162 },
163 },
164 SurfType::CylFresnel => Shape::Cylinder(base),
165 SurfType::UserShape => match self.user_shape() {
166 Some(shape) => Shape::User {
167 c,
168 k,
169 shape,
170 h: crate::usershape::paraxial_step(self.semi),
171 },
172 None => Shape::Conic { c, k },
173 },
174 SurfType::Irregular => Shape::Irregular(Irregular {
175 c,
176 k,
177 decenter: [p(0), p(1)],
178 tilt: [p(2), p(3)],
179 zs: p(4),
180 za: p(5),
181 zc: p(6),
182 angle: p(7),
183 radius: self.semi,
184 }),
185 SurfType::Fresnel
186 | SurfType::Jones
187 | SurfType::Paraxial
188 | SurfType::User
189 | SurfType::CoordBrk => Shape::Plane,
190 }
191 }
192
193 pub fn is_coord_break(&self) -> bool {
195 self.typ() == SurfType::CoordBrk
196 }
197
198 pub(crate) fn shape_params(&self) -> bool {
201 matches!(self.typ(), SurfType::Standard | SurfType::EvenAsph) || self.shape().is_freeform()
202 }
203
204 pub(crate) fn takes_shape_param(&self, kind: crate::param::Kind) -> bool {
206 self.shape_params() && self.shape().takes(kind)
207 }
208}
209
210pub fn sag(c: f64, k: f64, asph: &[f64], r2: f64) -> (f64, f64) {
212 let arg = 1.0 - (1.0 + k) * c * c * r2;
213 let root = if c != 0.0 { arg.max(0.0).sqrt() } else { 1.0 };
214 let mut z = c * r2 / (1.0 + root);
215 let mut dz = if c != 0.0 {
216 if arg > 0.0 {
217 c / (2.0 * root)
218 } else {
219 f64::NAN
220 }
221 } else {
222 0.0
223 };
224 for (i, &a) in asph.iter().enumerate() {
225 if a != 0.0 {
226 let i = (i + 1) as i32;
227 z += a * powi(r2, i);
228 dz += i as f64 * a * powi(r2, i - 1);
229 }
230 }
231 (z, dz)
232}
233
234#[inline(always)]
237pub fn powi(mut x: f64, n: i32) -> f64 {
238 debug_assert!(n >= 0);
239 let mut n = n as u32;
240 let mut r = 1.0;
241 loop {
242 if n & 1 != 0 {
243 r *= x;
244 }
245 n /= 2;
246 if n == 0 {
247 return r;
248 }
249 x *= x;
250 }
251}
252
253pub fn sag_toroidal(c: f64, k: f64, asph: &[f64], cx: f64, x: f64, y: f64) -> (f64, f64, f64) {
256 let (zy, dzr) = sag(c, k, asph, y * y);
257 let dzy = 2.0 * y * dzr;
258 if cx == 0.0 {
259 return (zy, 0.0, dzy);
260 }
261 let b = 1.0 - cx * zy;
263 if !(b > 0.0) {
264 return (f64::NAN, f64::NAN, f64::NAN);
265 }
266 let ce = cx / b;
267 let arg = 1.0 - ce * ce * x * x;
268 if !(arg > 0.0) {
269 return (f64::NAN, f64::NAN, f64::NAN);
270 }
271 let root = arg.sqrt();
272 (zy + ce * x * x / (1.0 + root), ce * x / root, dzy / root)
273}
274
275#[inline(always)]
280pub(crate) fn conic_root(ff: f64, gg: f64, aa: f64, disc: f64, sig: f64) -> f64 {
281 let q = sig * disc.sqrt();
282 if gg * sig >= 0.0 {
283 ff / (gg + q)
284 } else if aa != 0.0 {
285 (gg - q) / aa
286 } else {
287 ff / (2.0 * gg)
288 }
289}
290
291#[inline]
293fn zernike_sag(base: Base<'_>, terms: Option<&ZernSag>, x: f64, y: f64) -> (f64, f64, f64) {
294 let (mut z, mut zx, mut zy) = even_xy(base.c, base.k, base.a, x, y);
295 if let Some(zs) = terms {
296 let (a, ax, ay) = zs.eval(x, y);
297 z += a;
298 zx += ax;
299 zy += ay;
300 }
301 (z, zx, zy)
302}
303
304#[inline]
307fn grid_sag(
308 base: Base<'_>,
309 terms: Option<&ZernSag>,
310 grid: Option<&GridSag>,
311 x: f64,
312 y: f64,
313) -> (f64, f64, f64) {
314 let (mut z, mut zx, mut zy) = zernike_sag(base, terms, x, y);
315 if let Some(g) = grid {
316 match g.eval(x, y) {
317 Some((a, ax, ay)) => {
318 z += a;
319 zx += ax;
320 zy += ay;
321 }
322 None => return (f64::NAN, f64::NAN, f64::NAN),
323 }
324 }
325 (z, zx, zy)
326}
327
328#[inline]
330fn even_xy(c: f64, k: f64, a: &[f64], x: f64, y: f64) -> (f64, f64, f64) {
331 let (z, dz) = sag(c, k, a, x * x + y * y);
332 (z, 2.0 * dz * x, 2.0 * dz * y)
333}
334
335#[inline]
337fn r2_curv(c: f64, a: &[f64]) -> f64 {
338 c + 2.0 * a.first().copied().unwrap_or(0.0)
339}
340
341impl Irregular {
342 pub(crate) fn rot(&self) -> [[[f64; 3]; 3]; 3] {
344 let (tx, ty) = (self.tilt[0].to_radians(), self.tilt[1].to_radians());
345 let (sx, cx) = tx.sin_cos();
346 let (sy, cy) = ty.sin_cos();
347 [
348 [
349 [cy, 0.0, sy],
350 [sx * sy, cx, -sx * cy],
351 [-cx * sy, sx, cx * cy],
352 ],
353 [
354 [0.0, 0.0, 0.0],
355 [cx * sy, -sx, -cx * cy],
356 [sx * sy, cx, -sx * cy],
357 ],
358 [
359 [-sy, 0.0, cy],
360 [sx * cy, 0.0, sx * sy],
361 [-cx * cy, 0.0, -cx * sy],
362 ],
363 ]
364 }
365
366 pub(crate) fn local(&self, x: f64, y: f64) -> (f64, f64, f64) {
369 let (zs, za, zc, ang) = (self.zs, self.za, self.zc, self.angle.to_radians());
370 let (z0, dz) = sag(self.c, self.k, &[], x * x + y * y);
371 let (mut z, mut zx, mut zy) = (z0, 2.0 * dz * x, 2.0 * dz * y);
372 let r = self.radius;
373 if r > 0.0 && (zs != 0.0 || za != 0.0 || zc != 0.0) {
374 let (sa, ca) = ang.sin_cos();
375 let v = (-x * sa + y * ca) / r;
376 let rho2 = (x * x + y * y) / (r * r);
377 let (r2x, r2y) = (2.0 * x / (r * r), 2.0 * y / (r * r));
378 let (vx, vy) = (-sa / r, ca / r);
379 z += zs * rho2 * rho2 + za * v * v + zc * rho2 * v;
380 zx += zs * 2.0 * rho2 * r2x + za * 2.0 * v * vx + zc * (r2x * v + rho2 * vx);
381 zy += zs * 2.0 * rho2 * r2y + za * 2.0 * v * vy + zc * (r2y * v + rho2 * vy);
382 }
383 (z, zx, zy)
384 }
385
386 pub fn sag(&self, x: f64, y: f64) -> (f64, f64, f64) {
389 let (dx, dy) = (self.decenter[0], self.decenter[1]);
390 let m = self.rot()[0];
392 let q = |px: f64, py: f64, pz: f64| -> [f64; 3] {
393 [
394 m[0][0] * px + m[1][0] * py + m[2][0] * pz,
395 m[0][1] * px + m[1][1] * py + m[2][1] * pz,
396 m[0][2] * px + m[1][2] * py + m[2][2] * pz,
397 ]
398 };
399 let (px, py) = (x - dx, y - dy);
400 let mut z = self.local(px, py).0;
401 for _ in 0..50 {
402 let qq = q(px, py, z);
403 let (f, fx, fy) = self.local(qq[0], qq[1]);
404 let g = qq[2] - f;
406 let gz = m[2][2] - fx * m[2][0] - fy * m[2][1];
407 if !(g.is_finite() && gz.is_finite()) || gz == 0.0 {
408 return (f64::NAN, f64::NAN, f64::NAN);
409 }
410 let step = g / gz;
411 z -= step;
412 if step.abs() <= 1e-15 * (1.0 + z.abs()) {
413 break;
414 }
415 }
416 let qq = q(px, py, z);
417 let (_, fx, fy) = self.local(qq[0], qq[1]);
418 let gz = m[2][2] - fx * m[2][0] - fy * m[2][1];
419 let gx = m[0][2] - fx * m[0][0] - fy * m[0][1];
420 let gy = m[1][2] - fx * m[1][0] - fy * m[1][1];
421 (z, -gx / gz, -gy / gz)
422 }
423}
424
425fn zern_grid_curv(base: Base, terms: Option<&ZernSag>, grid: Option<&GridSag>) -> f64 {
427 let mut c = r2_curv(base.c, base.a);
428 if let Some(z) = terms {
429 let a4 = z.coef.get(3).copied().unwrap_or(0.0);
430 let k = if z.fringe { 4.0 } else { 4.0 * 3f64.sqrt() };
431 c += k * a4 / (z.norm * z.norm);
432 }
433 if let Some(g) = grid.filter(|g| !g.linear) {
434 let h = 1e-5;
435 let a = g.eval(0.0, h).map_or(0.0, |v| v.2);
436 let b = g.eval(0.0, -h).map_or(0.0, |v| v.2);
437 c += (a - b) / (2.0 * h);
438 }
439 c
440}
441
442fn toroidal_isect(c: f64, kc: f64, a: &[f64], cx: f64, pl: V3, kl: V3, sig: f64) -> (f64, bool) {
445 let mut s = 0.0;
446 if c != 0.0 {
447 let ff = c * pl[1] * pl[1];
448 let gg = kl[2] - c * pl[1] * kl[1];
449 let aa = c * (kl[1] * kl[1] + (1.0 + kc) * kl[2] * kl[2]);
450 let disc = gg * gg - aa * ff;
451 if disc >= 0.0 {
452 let s0 = conic_root(ff, gg, aa, disc, sig);
453 if s0.is_finite() {
454 s = s0;
455 }
456 }
457 }
458 let mut bad = false;
459 if cx != 0.0 || a.iter().any(|&v| v != 0.0) || s == 0.0 && c != 0.0 {
460 let mut ds = f64::NAN;
461 for _ in 0..60 {
462 let q = add(pl, scale(kl, s));
463 let (z, zx, zy) = sag_toroidal(c, kc, a, cx, q[0], q[1]);
464 ds = (q[2] - z) / (kl[2] - zx * kl[0] - zy * kl[1]);
465 s -= ds;
466 if !(ds.abs() > crate::trace::newton_tol(s, z)) {
467 break;
468 }
469 }
470 bad = !(ds.abs() <= 1e-10);
471 }
472 (s, bad)
473}
474
475impl Shape<'_> {
476 fn untilted_c(&self) -> Option<f64> {
478 match *self {
479 Shape::ConicTilted { c, tan, .. } if tan == [0.0; 2] => Some(c),
480 _ => None,
481 }
482 }
483
484 pub fn sag(&self, x: f64, y: f64) -> (f64, f64, f64) {
486 match *self {
487 Shape::Plane => (0.0, 0.0, 0.0),
488 Shape::Conic { c, k } => even_xy(c, k, &[], x, y),
489 Shape::EvenAsphere(b) => even_xy(b.c, b.k, b.a, x, y),
490 Shape::Cylinder(b) => {
491 let (z, dz) = sag(b.c, b.k, b.a, y * y);
492 (z, 0.0, 2.0 * dz * y)
493 }
494 Shape::Toroid { c, k, a, cx } => sag_toroidal(c, k, a, cx, x, y),
495 Shape::ConicTilted { c, k, tan } => {
496 let (z, dz) = sag(c, k, &[], x * x + y * y);
497 (
498 z + x * tan[0] + y * tan[1],
499 2.0 * dz * x + tan[0],
500 2.0 * dz * y + tan[1],
501 )
502 }
503 Shape::Tilted { tan: [a, b], .. } => (a * x + b * y, a, b),
504 Shape::Irregular(ir) => ir.sag(x, y),
505 Shape::OddAsphere { c, k, b } => {
506 let r2 = x * x + y * y;
507 let (z0, dz) = sag(c, k, &[], r2);
508 let (mut z, mut zx, mut zy) = (z0, 2.0 * dz * x, 2.0 * dz * y);
509 let r = r2.sqrt();
511 let (mut a, mut ar) = (0.0, 0.0);
512 for (i, &bi) in b.iter().enumerate() {
513 if bi != 0.0 {
514 let n = (i + 1) as i32;
515 a += bi * r.powi(n);
516 ar += n as f64 * bi * r.powi(n - 1);
517 }
518 }
519 z += a;
520 if r > 0.0 {
521 zx += ar * x / r;
522 zy += ar * y / r;
523 }
524 (z, zx, zy)
525 }
526 Shape::Zernike { base, terms } => zernike_sag(base, terms, x, y),
527 Shape::User { c, k, shape, .. } => {
528 let (z0, zx0, zy0) = even_xy(c, k, &[], x, y);
529 let (z, zx, zy) = shape.sag(x, y);
530 (z0 + z, zx0 + zx, zy0 + zy)
531 }
532 Shape::GridSag { base, terms, grid } => grid_sag(base, terms, grid, x, y),
533 }
534 }
535
536 pub fn is_freeform(&self) -> bool {
539 matches!(
540 self,
541 Shape::Zernike { .. }
542 | Shape::GridSag { .. }
543 | Shape::OddAsphere { .. }
544 | Shape::Tilted { .. }
545 | Shape::Irregular(_)
546 | Shape::User { .. }
547 )
548 }
549
550 pub fn paraxial_curv(&self) -> f64 {
560 match *self {
561 Shape::Plane | Shape::Tilted { .. } => 0.0,
562 Shape::Conic { c, .. } | Shape::ConicTilted { c, .. } => r2_curv(c, &[]),
563 Shape::EvenAsphere(b) | Shape::Cylinder(b) => r2_curv(b.c, b.a),
564 Shape::Toroid { c, a, .. } => r2_curv(c, a),
565 Shape::OddAsphere { c, b, .. } => c + 2.0 * b.get(1).copied().unwrap_or(0.0),
567 Shape::Irregular(ir) => ir.c,
568 Shape::Zernike { base, terms } => zern_grid_curv(base, terms, None),
569 Shape::GridSag { base, terms, grid } => zern_grid_curv(base, terms, grid),
570 Shape::User { c, shape, h, .. } => c + shape.paraxial_curv(h),
571 }
572 }
573
574 pub fn paraxial_extra(&self) -> Option<f64> {
579 match *self {
580 Shape::Conic { .. } | Shape::ConicTilted { .. } | Shape::Irregular(_) => Some(0.0),
581 Shape::EvenAsphere(Base { a, .. })
582 | Shape::Cylinder(Base { a, .. })
583 | Shape::Toroid { a, .. } => Some(2.0 * a.first().copied().unwrap_or(0.0)),
584 Shape::OddAsphere { b, .. } => Some(2.0 * b.get(1).copied().unwrap_or(0.0)),
585 Shape::User { shape, h, .. } => Some(shape.paraxial_curv(h)),
586 Shape::Plane | Shape::Tilted { .. } | Shape::Zernike { .. } | Shape::GridSag { .. } => {
587 None
588 }
589 }
590 }
591
592 pub(crate) fn isect_kind(&self) -> Isect {
594 if let Some(c) = self.untilted_c() {
595 return Shape::Conic { c, k: 0.0 }.isect_kind();
596 }
597 match *self {
598 Shape::Plane => Isect::Plane,
599 Shape::Conic { c, .. } => {
600 if c != 0.0 {
601 Isect::Std { asph: false }
602 } else {
603 Isect::Plane
604 }
605 }
606 Shape::EvenAsphere(b) => {
607 if b.c != 0.0 || b.has_terms() {
608 Isect::Std {
609 asph: b.has_terms(),
610 }
611 } else {
612 Isect::Plane
613 }
614 }
615 Shape::Toroid { c, a, cx, .. } => {
616 if c != 0.0 || cx != 0.0 || a.iter().any(|&v| v != 0.0) {
617 Isect::Newton
618 } else {
619 Isect::Plane
620 }
621 }
622 Shape::Cylinder(b) => {
623 if b.c != 0.0 || b.has_terms() {
624 Isect::Newton
625 } else {
626 Isect::Plane
627 }
628 }
629 Shape::ConicTilted { .. }
630 | Shape::Zernike { .. }
631 | Shape::GridSag { .. }
632 | Shape::OddAsphere { .. }
633 | Shape::Tilted { .. }
634 | Shape::Irregular(_)
635 | Shape::User { .. } => Isect::Newton,
636 }
637 }
638
639 pub(crate) fn norm_kind(&self) -> Norm {
641 if let Some(c) = self.untilted_c() {
642 return Shape::Conic { c, k: 0.0 }.norm_kind();
643 }
644 match *self {
645 Shape::Plane => Norm::Flat,
646 Shape::Conic { c, .. } => {
647 if c == 0.0 {
648 Norm::Flat
649 } else {
650 Norm::Conic
651 }
652 }
653 Shape::EvenAsphere(b) => {
654 if b.has_terms() {
655 Norm::Asph
656 } else if b.c == 0.0 {
657 Norm::Flat
658 } else {
659 Norm::Conic
660 }
661 }
662 _ => Norm::Grad,
663 }
664 }
665
666 pub(crate) fn normal(&self, p: V3) -> V3 {
668 match (self.norm_kind(), *self) {
669 (Norm::Flat, _) => [0.0, 0.0, 1.0],
670 (Norm::Conic, Shape::Conic { c, k } | Shape::ConicTilted { c, k, .. })
671 | (Norm::Conic, Shape::EvenAsphere(Base { c, k, .. })) => {
672 [-c * p[0], -c * p[1], 1.0 - c * (1.0 + k) * p[2]]
673 }
674 (Norm::Asph, Shape::EvenAsphere(b)) => {
675 let (_, dz) = sag(b.c, b.k, b.a, p[0] * p[0] + p[1] * p[1]);
676 [-2.0 * dz * p[0], -2.0 * dz * p[1], 1.0]
677 }
678 _ => {
679 let (_, zx, zy) = self.sag(p[0], p[1]);
680 [-zx, -zy, 1.0]
681 }
682 }
683 }
684
685 pub(crate) fn isect(&self, pl: V3, kl: V3, sig: f64) -> (f64, bool) {
689 match *self {
690 Shape::Toroid { c, k, a, cx } => toroidal_isect(c, k, a, cx, pl, kl, sig),
691 Shape::Cylinder(_) | Shape::Plane | Shape::Tilted { .. } => {
693 isect_with(0.0, 0.0, pl, kl, sig, |x, y| self.sag(x, y))
694 }
695 Shape::Zernike { base, terms } => isect_with(base.c, base.k, pl, kl, sig, |x, y| {
697 zernike_sag(base, terms, x, y)
698 }),
699 Shape::GridSag { base, terms, grid } => {
700 isect_with(base.c, base.k, pl, kl, sig, |x, y| {
701 grid_sag(base, terms, grid, x, y)
702 })
703 }
704 Shape::Conic { c, k }
705 | Shape::ConicTilted { c, k, .. }
706 | Shape::OddAsphere { c, k, .. }
707 | Shape::EvenAsphere(Base { c, k, .. })
708 | Shape::Irregular(Irregular { c, k, .. })
709 | Shape::User { c, k, .. } => isect_with(c, k, pl, kl, sig, |x, y| self.sag(x, y)),
710 }
711 }
712}
713
714#[derive(Debug, Clone, Copy, PartialEq, Eq)]
716pub(crate) enum Isect {
717 Plane,
719 Std { asph: bool },
721 Newton,
723}
724
725#[derive(Debug, Clone, Copy, PartialEq, Eq)]
727pub(crate) enum Norm {
728 Flat,
729 Conic,
730 Asph,
731 Grad,
733 Fresnel,
735}
736
737#[derive(Debug, Clone, Copy, PartialEq, Eq)]
739pub(crate) struct SurfKind {
740 pub isect: Isect,
741 pub norm: Norm,
742 pub fresnel: bool,
744 pub act: crate::action::Act,
745}
746
747pub(crate) fn surf_kind(d: &Surface) -> SurfKind {
749 let shape = d.shape();
750 let action = d.action();
751 let fresnel = matches!(action, Action::Fresnel(_));
752 let isect = shape.isect_kind();
753 let norm = if fresnel {
754 Norm::Fresnel
755 } else {
756 shape.norm_kind()
757 };
758 SurfKind {
759 isect,
760 norm,
761 fresnel,
762 act: crate::action::Act::of(d, &action),
763 }
764}
765
766pub(crate) fn local_normal(d: &Surface, pl: V3) -> V3 {
768 let action = d.action();
769 if d.is_coord_break()
770 || matches!(
771 action,
772 Action::Paraxial { .. } | Action::Jones(_) | Action::User(_)
773 )
774 {
775 return [0.0, 0.0, 1.0];
776 }
777 let v = match action {
778 Action::Fresnel(b) => b.normal(pl[0], pl[1]),
779 _ => d.shape().normal(pl),
780 };
781 normalize(v)
782}